Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Explain how to use transactions efficiently : transact sql

1019


Where can I learn sql for free?

1052


What is pl sql in dbms?

993


why does the selected column have to be in the group by clause or part of an aggregate function? : Sql dba

1164


how would you get the current date in mysql? : Sql dba

1020


What is the difference between between and in condition operators?

1069


What is sql resultset?

1043


What is data type in sql?

1006


what is the difference between primary key and unique key? : Sql dba

1087


Is sql an operating system?

1075


What is mutating error?

1010


Why is nosql good?

1085


What does the sign mean in sql?

1051


Which command is used to call a stored procedure?

1055


how to dump a table to a file with 'mysqldump'? : Sql dba

1103