oracle-databaseplsql

How can I count only NULL values in Oracle/PLSQL?


How can I count only NULL values in Oracle/PLSQL?

I want to count only the null values. Is there a function that does that?


Solution

  • I don't know Oracle specifally, but ANSI SQL, COUNT(rowName) does not count NULL values, but COUNT(*) does. So you can write

    SELECT COUNT(*) FROM YourTable WHERE YourColumn IS NULL
    

    which counts the rows in YourTable that have YourColumn set to NULL.