Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

query with two groupings required

Status
Not open for further replies.

nuct

Programmer
Sep 5, 2001
103
Hi i need to do a query which outputs results similar to this.

Female Male
1st 10 11
2:1 8 10
2:2 7 6
3rd 3 5

I only know how to group on one catagory, say gender, but once thats done how do you then group on grade. I don't need specific instructions, just a rough idea on how i should proceed.

Cheers

Simon.
 
I'm not sure how you're getting the first column, but I think what you could try is something like:

SELECT <however_you're_getting_the_first_column>,
SUM(DECODE(gender,'F',1,0)) female,
SUM(DECODE(gender,'M',1,0)) male
FROM my_table
GROUP BY <however_you're_getting_the_first_column>;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top