Oracle: How to count null and non-null rows

后端 未结 6 2040
猫巷女王i
猫巷女王i 2021-02-04 01:38

I have a table with two columns that might be null (as well as some other columns). I would like to count how many rows that have column a, b, both and neither colu

6条回答
  •  再見小時候
    2021-02-04 01:55

    It can be accomplished in Oracle just in 1 row:

    SELECT COUNT(NVL(potential_null_column, 0)) FROM table;
    

    Function NVL checks if first argument is null and treats it as value from second argument.

提交回复
热议问题