Question: Below is the table

city gender name
delhi male a
delhi female b
mumbai male c
mumbai female d
delhi male e

I want the o/p as follows:

male female
delhi 2 1
mumbai 1 1

Please help me in writing the query that can yield the o/p
mentioned above?

Answer Posted / kavitha nedigunta

select city,
count(decode(lower(gender),'male','female',null)) male,
count(decode(lower(gender),'female','male',null)) female
from gen
group by city;

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Does user triggers have entry for trigger with compilation errors?

796


What is the difference between python and sql?

709


What is delimiter in pl sql?

743


What are properties of the transaction?

727


What does count (*) mean?

684






How do I make sql search faster?

768


What are the types of records?

747


What are triggers in sql?

751


what are date and time data types? : Sql dba

704


What can sql server reporting services do?

794


Can you have more than one trigger on a table?

712


What is join view in sql?

698


what are the features and advantages of object-oriented programming? : Sql dba

727


how to drop an existing index in mysql? : Sql dba

715


How do you know if a relationship is 2nf?

692