Back
I have a table
create table us( a number);
create table us
(
a number
);
Now I have data like:
a1234nullnullnull89
a
1
2
3
4
null
8
9
Now I need a single query to count null and not null values in column a
The below code will work for Oracle and SQL Server:
select sum(case when a is null then 1 else 0 end) count_nulls , count(a) count_not_nulls from us;
select sum(case when a is null then 1 else 0 end) count_nulls
, count(a) count_not_nulls
from us;
Otherwise, you can use this:
select count(*) - count(a), count(a) from us;
31k questions
32.8k answers
501 comments
693 users