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

Which operator is used in query for pattern matching?

740


What is the example of procedure?

596


What is a native sql query?

586


what is 'mysqlcheck'? : Sql dba

655


What does inner join mean?

662






How do you delete duplicates in sql query using rowid?

634


What are predefined functions in sql?

615


what are the disadvantages of mysql? : Sql dba

658


Lookups are a key component in sql server integration services (ssis). Explain its purpose?

636


Inline the values in PL/SQL, what does it mean.?

736


Define join and name different types of joins?

621


what are properties of a transaction? : Sql dba

657


How to start the command-line sql*plus?

654


What is a temp table?

663


What is PL/SQL Records?

721