Counting null and non-null values in a single query

后端 未结 26 1087
星月不相逢
星月不相逢 2021-01-29 19:31

I have a table

create table us
(
 a number
);

Now I have data like:

a
1
2
3
4
null
null
null
8
9

Now I need

26条回答
  •  一向
    一向 (楼主)
    2021-01-29 19:51

    Number of elements where a is null:

    select count(a) from us where a is null;
    

    Number of elements where a is not null:

    select count(a) from us where a is not null;
    

提交回复
热议问题