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 -> Re: Left Outer Join, group by, and date-based queries

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

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 18 Nov 2005 14:30:53 -0800
Message-ID: <1132353051.13609@yasure>


bbcrock_at_gmail.com wrote:
> 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

www.psoug.org
Click on Morgan's Library
click on Joins

-- 
Daniel A. Morgan
http://www.psoug.org
damorgan_at_x.washington.edu
(replace x with u to respond)
Received on Fri Nov 18 2005 - 16:30:53 CST

Original text of this message

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