Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Left Outer Join, group by, and date-based queries

Left Outer Join, group by, and date-based queries

From: <bbcrock_at_gmail.com>
Date: 18 Nov 2005 13:39:14 -0800
Message-ID: <1132349953.995940.153250@g43g2000cwa.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US