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?
Answers were Sorted based on User's Feedback
Answer / kavitha nedigunta
select city,
count(decode(lower(gender),'male','female',null)) male,
count(decode(lower(gender),'female','male',null)) female
from gen
group by city;
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / 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 |
What is sql table?
How many sql are there?
Is sqlite good enough for production?
How do I kill a query in postgresql?
What is the purpose of cursors in pl/sql?
What is sqlerrm?
What is data profiling in sql?
How does postgresql compare to mysql?
How can you create an empty table from an existing table?
What is the need of merge statement?
What is pl/sql language case sensitive?
What are the types pl/sql code blocks?