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

What are expressions?

561


What is sql constant?

503


Will truncate release space?

514


What is left join in postgresql?

534


What is sql used for?

642






How to select unique records from a table?

567


What is difference between pls_integer and integer?

516


what does it mean to have quoted_identifier on? What are the implications of having it off? : Sql dba

525


what is the functionality of the function htmlentities? : Sql dba

517


What is sqlcontext?

549


What is update query?

547


What is the use of primary key?

535


Can we write ddl statements in functions?

562


What is output spooling in sql*plus?

549


What is lexical units in pl sql?

565