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
Is foreign key mandatory?
What is the difference between inner join and natural join?
What are secondary keys?
Why do we need unique key in a table?
Is there a pl/sql pragma similar to deterministic, but for the scope of one single sql select?
Which is better join or subquery?
What is snowflake sql?
What are different types of sql?
How do I debug a stored procedure?
Does db2 use sql?
How to select the Nth maximum salary from Table Emp in Oracle SQL Plus ?
What does := mean in pl sql?
What is a procedure in pl sql?
What is difference between sql and oracle?
Can we use join in subquery?