Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return 0 With Null Value

Status
Not open for further replies.

db2mo

Programmer
Mar 29, 2011
4
US
I have a Select statement which is doing a count. For the column that is being counted, I want the null values that are returned to be 0. I've tried using ISNULL and IFNULL, but no luck. Here's the part of the code that I need to return 0 instead of null:
(SELECT COUNT(QO01ACCIDENT_NO) AS CNT, ACCTYP, SEVERITY, GROUPING(ACCTYP) AS ACCTYP_GROUP, GROUPING(SEVERITY) AS SEVERITY_GROUP

 
Have you tried:
Code:
 ISNULL(SELECT COUNT(QO01ACCIDENT_NO) AS CNT, ACCTYP, SEVERITY, GROUPING(ACCTYP) AS ACCTYP_GROUP, GROUPING(SEVERITY), 0) AS SEVERITY_GROUP

--------------------------------------------------
“Crash programs fail because they are based on the theory that, with nine women pregnant, you can get a baby a month.” --Wernher von Braun
--------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top