Discussion:
Count of NULL and NOT NULLS
(too old to reply)
Jim
2006-12-15 22:38:38 UTC
Permalink
How would I write a query to count the number of instances where a the
PREP field is NULL and when it is not null. I know how to do it
seperately, can I get the numbers in the same query. I want something
like this

Project #PREP_NOTNULL #PREP_NULL

Thanks,

Jim
que
2006-12-16 07:43:59 UTC
Permalink
select concat('isnull(prep) = ' ,isnull(prep)) `condition`, count(*)
`count` from your_table group by isnull(prep)
Post by Jim
How would I write a query to count the number of instances where a the
PREP field is NULL and when it is not null. I know how to do it
seperately, can I get the numbers in the same query. I want something
like this
Project #PREP_NOTNULL #PREP_NULL
Thanks,
Jim
Jim
2006-12-18 17:20:46 UTC
Permalink
Thanks,

Is there a way to get the counts in the same ROW
Post by que
select concat('isnull(prep) = ' ,isnull(prep)) `condition`, count(*)
`count` from your_table group by isnull(prep)
Post by Jim
How would I write a query to count the number of instances where a the
PREP field is NULL and when it is not null. I know how to do it
seperately, can I get the numbers in the same query. I want something
like this
Project #PREP_NOTNULL #PREP_NULL
Thanks,
Jim
que
2006-12-20 08:03:50 UTC
Permalink
select count(*) nulls, (select count(*) from your_table where not
isnull(prep)) not_nulls from your_table where isnull(prep)
Post by Jim
Is there a way to get the counts in the same ROW
Loading...