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

What are the types of queries in sql?

1086


Is natural join same as inner join?

945


When can we use the where clause and the having clause?

1021


Can primary key be changed?

911


What is cursor and its types?

1076


Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?

1103


How to find 3rd highest salary of an employee from the employee table in sql?

1083


What is coalesce in sql?

1064


what is a database? : Sql dba

1175


Explain the difference between 'between' & 'and' operators in sql

1004


How can we implement rollback or commit statement in a trigger?

1041


How do I run sql?

1192


Can we call a function containing dml statements in a select query?

981


Is sql a case sensitive language?

950


how to write date and time literals? : Sql dba

964