Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle Left Outer Join and totals
<bbcrock_at_gmail.com> a écrit dans le message de news: 1148323051.803427.320640_at_j55g2000cwa.googlegroups.com...
|I want to get the following result, but can't seem to do it in one
| query. should be very simple, but I can't wrap my head around it. I
| have 4 teams and want to select the count on the number of reports per
| team. Most commonly this number will be zero. Report should look
| like:
|
| Team A (3)
| Team B (2)
| Team C (0)
| Team D (0)
|
| I did a left outer join on team and count(reports) and of course got:
|
| Team A (3)
| Team B (2)
| Team C (1)
| Team D (1)
|
| because there was a single null row for every left item in the Left
| Outer Join.
|
| I presume I need to do a subselect, but I can't make it work. Feel
| free to point me to Ask Tom, I'm using the wrong syntax to search for
| this solution- drawing a total blank here!
|
| thanks for any help!
|
| Don
|
Feel free to post your Oracle version, ddl and query you tested.
Regards
Michel Cadot
Received on Mon May 22 2006 - 13:52:35 CDT