| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Mailing Lists -> Oracle-L -> count(*) = 0 and I still need the row
Hi All,
Thanks to Javier, Ron, William and Deepak for their efforts
I have not tried Ron's solution of pre-setting the variable
yet, thats next.
I have tried outer joins:
SELECT
hp.URL,
nvl(count(pv.HTML_PAGE_ID),0)
FROM PAGE_VIEWS pv, HTMP_PAGE hp
WHERE hp.PAGE_ID = pv.HTML_PAGE_ID(+)
GROUP BY hp.URL
Returns
The HideAway 1
The Townsend 0
Tony's Place 0
Yet Another 0
available 0
creepy condo's 2
slumpers 3
twomonthsago 2
Add in the date restriction:
SELECT
hp.URL,
nvl(count(pv.HTML_PAGE_ID),0)
FROM PAGE_VIEWS pv, HTMP_PAGE hp
WHERE hp.PAGE_ID = pv.HTML_PAGE_ID (+)
AND pv.VIEW_DATE > add_months(SYSDATE, -1);
GROUP BY hp.URL
Returns
The HideAway 1
creepy condo's 2
slumpers 3
And people believe I know what I'm doing????
It does process the row "twomonthsago" semi-properly as those pageviews are more than 1 month ago. (Yes the data was created to be meaningful) I say semi-properly because it should display
twomonthsago 0
Anyone know why the the date test alters the outer join results?
TIA
Dave
-- Dave Morgan Senior Database Administrator Internet Barter Inc.Received on Thu Nov 16 2000 - 14:05:09 CST
![]() |
![]() |