![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a simple query: SELECT SUM(cases_escalated) AS casesescalated FROM groupsummary WHERE report_date=TO_DATE('Sep 2007','MON YYYY') AND group_name = 'T1'; The query works fine, except for when there is nothing to SUM and then I get returned NULL instead of 0. My question is how can I get the query to display 0 instead of 'blank'; I read something about using a join, but I don't see how joining would help me as right now this is the only table in my database. Would I somehow join against a query to DUAL? |
#3
| |||
| |||
|
|
I have a simple query: SELECT SUM(cases_escalated) AS casesescalated FROM groupsummary WHERE report_date=TO_DATE('Sep 2007','MON YYYY') AND group_name = 'T1'; The query works fine, except for when there is nothing to SUM and then I get returned NULL instead of 0. My question is how can I get the query to display 0 instead of 'blank'; I read something about using a join, but I don't see how joining would help me as right now this is the only table in my database. Would I somehow join against a query to DUAL? By not summing NULLs: sum(nvl(cases_escalated,0)), |
#4
| |||
| |||
|
|
On Nov 1, 1:55 pm, trp... (AT) gmail (DOT) com wrote: I have a simple query: SELECT SUM(cases_escalated) AS casesescalated FROM groupsummary WHERE report_date=TO_DATE('Sep 2007','MON YYYY') AND group_name = 'T1'; The query works fine, except for when there is nothing to SUM and then I get returned NULL instead of 0. My question is how can I get the query to display 0 instead of 'blank'; I read something about using a join, but I don't see how joining would help me as right now this is the only table in my database. Would I somehow join against a query to DUAL? SELECT SUM(nvl(cases_escalated, 0)) AS casesescalated FROM groupsummary WHERE report_date=TO_DATE('Sep 2007','MON YYYY') AND group_name = 'T1'; David Fitzjarrell |
#5
| |||
| |||
|
|
trp... (AT) gmail (DOT) com wrote: I have a simple query: SELECT SUM(cases_escalated) AS casesescalated FROM groupsummary WHERE report_date=TO_DATE('Sep 2007','MON YYYY') AND group_name = 'T1'; The query works fine, except for when there is nothing to SUM and then I get returned NULL instead of 0. My question is how can I get the query to display 0 instead of 'blank'; I read something about using a join, but I don't see how joining would help me as right now this is the only table in my database. Would I somehow join against a query to DUAL? By not summing NULLs: sum(nvl(cases_escalated,0)), or by decoding the NULL: nvl(sum(cases_escalated),0) Which ever way you want it -- Regards, Frank van Bortel Top-posting is one way to shut me up... |
![]() |
| Thread Tools | |
| Display Modes | |
| |