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



Question: Below is the table city gender name delhi male ..

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

Question: Below is the table city gender name delhi male ..

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

Post New Answer

More SQL PLSQL Interview Questions

What is the difference between cluster and non-cluster index?

0 Answers  


How does join work in sql?

0 Answers  


How can I speed up sql query?

0 Answers  


What are the ddl commands?

0 Answers  


How many sql commands are there?

0 Answers  






What is indexing oracle sql?

0 Answers  


Explain the working of foreign key?

0 Answers  


What does rownum mean in sql?

0 Answers  


What are stored procedures used for?

0 Answers  


What is a sql instance vs database?

0 Answers  


In pl/sql, what is bulk binding, and when/how would it help performance?

0 Answers  


there is A table and B table in A table there 5 rows and in b table there are 2 rows i am firing query select * from a,b what will be the output?

7 Answers   Cognizant,


Categories