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
What is view explain with example?
What is Collation Sensitivity ? What are the various type ?
what is a trigger in mysql? Define different types of trigger. : Sql dba
Which query operators in sql is used for pattern matching?
What is the sql*loader? : aql loader
Is pl sql a scripting language?
Can we commit in trigger?
How is debugging done?
How do you take the union of two tables in sql?
what are the properties and different types of sub-queries? : Sql dba
define sql update statement ? : Sql dba
Why truncate is used in sql?
Are subqueries better than joins?
How do I save the results of sql query in a file?
What is the order of sql select?