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 will you get by the cursor attribute sql%notfound?
How can we store rows in PL/SQL using array?
What are the set operators in sql?
What is db journal file?
what is the bond code in materialized view?
What is sql scripting?
What is cte?
What is coalesce sql?
How exception is different from error?
How would you pass hints to the sql processor?
which operator is used in query for pattern matching? : Sql dba
What is the location of pre_defined_functions.
Does sql full backup truncate logs?
How does rowid help in running a query faster?
Is there any restriction on the use of union in embedded sql?