Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Left Outer Join, group by, and date-based queries
My second post here this afternoon- I should just go home.
I want to write a query that returns all months for a year and the total number of incidents per month IF they exist.
Current query looks like:
select to_char(trunc(logindate, 'month'), 'YYYY Mon') Month, count(*)
total
from logtable
where event = 'LOGIN'
[and other filters]
group by trunc(logindate, 'month')
I cannot remember for the life of me how to write a Left Outer Join type query on ALL possible months. My results here skip months if no value exists, returning 10 aggregate values for 2004 data when it should be 12 rows and two of the rows should have 0 results. How does one do this without creating a table containing month information, etc?
thanks,
Don Received on Fri Nov 18 2005 - 15:39:14 CST