Oracle: How to count null and non-null rows

后端 未结 6 2042
猫巷女王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:57

    One way to do it would be:

    select count(*) from table group by nvl2(a, 0, 1), nvl2(b, 0, 1) having nvl2(a,0,1) = nvl2(b,0,1);
    

提交回复
热议问题