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 sp_helptext?
what are the differences between public, private, protected, static, transient, final and volatile? : Sql dba
Does truncate remove indexes?
What is difference between function and trigger?
what is bcp? When does it used? : Sql dba
How do you copy a table in sql?
What is the maximum number of triggers, you can apply on a single table?
Explain the purpose of %type and %rowtype data types?
What is union, minus and interact commands?
Is it possible to pass parameters to triggers?
What is type and rowtype in pl sql?
Is sql dba a good career? : SQL DBA
How are sql commands classified?
Define the select into statement.
What are the different types of tables in sql?