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
What are the types of queries in sql?
Is natural join same as inner join?
When can we use the where clause and the having clause?
Can primary key be changed?
What is cursor and its types?
Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?
How to find 3rd highest salary of an employee from the employee table in sql?
What is coalesce in sql?
what is a database? : Sql dba
Explain the difference between 'between' & 'and' operators in sql
How can we implement rollback or commit statement in a trigger?
How do I run sql?
Can we call a function containing dml statements in a select query?
Is sql a case sensitive language?
how to write date and time literals? : Sql dba