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

Home -> Community -> Mailing Lists -> Oracle-L -> count(*) = 0 and I still need the row

count(*) = 0 and I still need the row

From: Dave Morgan <dmorgan_at_bartertrust.com>
Date: Wed, 15 Nov 2000 08:24:09 -0800
Message-Id: <10681.122117@fatcity.com>


Hi All,

	For the SQL experts out there. 
	I have the tables

	PAGE_VIEWS
		VIEW_ID		NUMBER(10,0)
		HTML_PAGE_ID	NUMBER(10,0)
		VIEW_DATE	DATE

	HTML_PAGE
		PAGE_ID		NUMBER(10,0)
		URL		VARCHAR2(255)
		....

	PAGE_VIEWS.HTML_PAGE_ID is a foreign key to HTML_PAGE.PAGE_ID
	I want to get a list of all pages and number of times they are viewed
	in the past month. 

	SELECT
		hp.URL,
		count(pv.HTML_PAGE_ID)
	FROM
		PAGE_VIEWS pv, HTMP_PAGE hp
	WHERE 
		hp.PAGE_ID = pv.HTML_PAGE_ID
	AND
		pv.VIEW_DATE > addmonths(SYSDATE, -1);

	This works fine except when the page has not been viewed in which
	case it does not show up in the report. I would like it to show up
	with the number 0. Any ideas?

	This is in a stored procedure so I can be very flexible.

TIA
Dave

-- 
Dave Morgan
Senior Database Administrator
Internet Barter Inc.
Received on Wed Nov 15 2000 - 10:24:09 CST

Original text of this message

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