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 -> Add zero for null in count?

Add zero for null in count?

From: <dan-x_at_yahoo.com>
Date: 13 Sep 2006 13:52:09 -0700
Message-ID: <1158180729.436070.319190@m73g2000cwd.googlegroups.com>


Hey. I have a SQL*Plus query where I'm counting unique values. How can I get it to return a zero if no data matches the query's criteria?

Here's my query:
SELECT distinct r.dstr_nr, COUNT(DISTINCT r.RGSN_ID) "DAILY TOTAL" FROM RGSN r
WHERE r.DSTR_NR between 1603 and 1700
and trunc(applied_dt) = '12-SEP-2006'
group by r.dstr_nr
order by r.dstr_nr desc
/

Let's say it's displaying this right now...

DSTR_NR       DAILY TOTAL
1603               153
1604               23
1606               98

I want it to display this...
DSTR_NR       DAILY TOTAL
1603               153
1604               23
1605               0
1606               98
1607               0

Any help is appreciated.
Thanks,
-Danny Received on Wed Sep 13 2006 - 15:52:09 CDT

Original text of this message

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