Sample Header Ad - 728x90

not return count = 0 if value is null - oracle

-1 votes
2 answers
387 views
I'm trying to write a oracle SQL query to return if the values are not present then return the count as zero. My query : select company, sum(case when company IN ('ABC','DEF','GHI','JKL','MNO') then 1 else 0 end) count from table_name where trunc(msg_date) = trunc(sysdate) group by soc_id; Actual output | COMPANY | COUNT | | -------- | -------------- | | ABC | 1| | DEF | 2| | GHI| 3| | JKL | 7| Expected Output: | COMPANY | COUNT | | -------- | -------------- | | ABC | 1| | DEF | 2| | GHI| 3| | JKL | 7| | MNO | 0| Expected Output doesnot print any values of 'MNO' company. Is there any chance, we have oracle SQL query to solve this issue ? your response is much appreciated.
Asked by Karthik Awesomes (1 rep)
Jan 24, 2024, 10:21 AM
Last activity: Feb 2, 2024, 01:52 PM