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!

Fetch count of null and non-null rows in table

A3006Jun 8 2021

Hi all,
I have a requirement to check in one query, the count of null and not-null rows in a table.
I am using Oracle 12C and below is a sample of the data:
CREATE TABLE TEST(E2B_ID NUMBER);
INSERT ALL
INTO TEST VALUES(1)
INTO TEST VALUES(2)
INTO TEST VALUES(NULL)
INTO TEST VALUES(NULL)
INTO TEST VALUES(3)
INTO TEST VALUES(4)
SELECT * FROM DUAL;

Expected O/P is:
COUNT(NULL ROWS) | COUNT(NOTNULL ROWS)
2 4
Is there a way to get the data in 1 query i.e. I want 2 columns as the resultant query. Both with null and not null rows count,

This post has been answered by User_H3J7U on Jun 8 2021
Jump to Answer
Comments
Post Details
Added on Jun 8 2021
3 comments
711 views