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 / sp

SELECT
city, COUNT(
CASE gender
WHEN 'male' THEN 'male'
END ) AS 'male' ,COUNT(
CASE gender
WHEN 'female' THEN 'female'
END ) AS 'female'
FROM info AS u group by city;

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is view explain with example?

937


What is Collation Sensitivity ? What are the various type ?

954


what is a trigger in mysql? Define different types of trigger. : Sql dba

1073


Which query operators in sql is used for pattern matching?

970


What is the sql*loader? : aql loader

1058


Is pl sql a scripting language?

1035


Can we commit in trigger?

981


How is debugging done?

985


How do you take the union of two tables in sql?

989


what are the properties and different types of sub-queries? : Sql dba

1036


define sql update statement ? : Sql dba

1126


Why truncate is used in sql?

1010


Are subqueries better than joins?

978


How do I save the results of sql query in a file?

980


What is the order of sql select?

1043