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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How does stored procedure reduce network traffic?

971


Is it possible for a table to have more than one foreign key?

982


How does a trigger work?

990


What is crud sql?

927


What are pl/sql cursor exceptions?

1037


How do I count rows in sql?

952


what are the limitations of mysql in comparison of oracle? Mysql vs. Oracle. : Sql dba

903


Is sql easier than java?

947


What is trigger and types?

968


How can you save or place your msg in a table?

956


Can we use joins in subquery?

1089


What is the difference between a database and a relational database?

1040


Which table is left in join?

916


Can we rollback delete command?

940


How can a function retun more than one value in oracle with proper example?

1031