Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

how to add a new column to an existing table in mysql? : Sql dba

0 Answers  


how to calculate the difference between two dates? : Sql dba

0 Answers  


How many types of normalization are there?

0 Answers  


Why do we need databases?

0 Answers  


Describe the Index, Types of index, At what situation we have used? Which one s better than others?

1 Answers   IBM, TCS,


How can one get sql*loader to commit only at the end of the load file? : aql loader

0 Answers  


Why do we use sql constraints?

0 Answers  


Which data type doesn't allow null data type?

6 Answers   TCS,


Can we alter stored procedure?

0 Answers  


What does an inner join do?

0 Answers  


How well can multiple sessions access the same data simultaneously ?

1 Answers   Oracle,


How do I restart sql?

0 Answers  


Categories