Oracle: How to count null and non-null rows

后端 未结 6 2043
猫巷女王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 02:08

    select sum(decode(a,null,0,1)) as "NotNullCount", sum(decode(a,null,1,0)) as "NullCount"
    from myTable;
    

    Repeat for as many fields as you like.

提交回复
热议问题