Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL - Case Grouping

abhijit74Mar 28 2011 — edited Mar 28 2011
Hello Everybody,
I am trying to get a count of all null values v/s non null values in a table. I am trying to use the CASE statement to do this.
I have formed the following SQL so far.
SELECT count(Aj.Asset_Hdr_Id),
       CASE Nvl(Aj.Asset_Hdr_Id,
            0)
         WHEN 0 THEN
          'IS NULL'
         ELSE
          'IS NOT NULL'
       END
  FROM Asset_Jt Aj
 GROUP BY Nvl(Aj.Asset_Hdr_Id, 0);
This is not giving me the desired result. My desired result will look like
2089 IS NULL
12340 IS NOT NULL
I am getting a result that looks like this
1	0	IS NULL
2	1	IS NOT NULL
3	1	IS NOT NULL
4	1	IS NOT NULL
5	1	IS NOT NULL
This post has been answered by Ganesh Srivatsav on Mar 28 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2011
Added on Mar 28 2011
6 comments
258 views