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
Explain how to use transactions efficiently : transact sql
Where can I learn sql for free?
What is pl sql in dbms?
why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba
how would you get the current date in mysql? : Sql dba
What is the difference between between and in condition operators?
What is sql resultset?
What is data type in sql?
what is the difference between primary key and unique key? : Sql dba
Is sql an operating system?
What is mutating error?
Why is nosql good?
What does the sign mean in sql?
Which command is used to call a stored procedure?
how to dump a table to a file with 'mysqldump'? : Sql dba