Count of NULL and NOT NULLS

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
jferree [ Fr, 15 Dezember 2006 23:38 ] [ ID #1568979 ]

Re: Count of NULL and NOT NULLS

select concat('isnull(prep) =3D ' ,isnull(prep)) `condition`, count(*)
`count` from your_table group by isnull(prep)

Jim =ED=E0=EF=E8=F1=E0=E2:
> 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 [ Sa, 16 Dezember 2006 08:43 ] [ ID #1569909 ]

Re: Count of NULL and NOT NULLS

Thanks,

Is there a way to get the counts in the same ROW



que wrote:
> select concat('isnull(prep) =3D ' ,isnull(prep)) `condition`, count(*)
> `count` from your_table group by isnull(prep)
>
> Jim =ED=E0=EF=E8=F1=E0=E2:
> > 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
jferree [ Mo, 18 Dezember 2006 18:20 ] [ ID #1571257 ]

Re: Count of NULL and NOT NULLS

select count(*) nulls, (select count(*) from your_table where not
isnull(prep)) not_nulls from your_table where isnull(prep)

>
> Is there a way to get the counts in the same ROW
>
que [ Mi, 20 Dezember 2006 09:03 ] [ ID #1573542 ]
Datenbanken » mailing.database.mysql » Count of NULL and NOT NULLS

Vorheriges Thema: SELECT multiple rows with average of a range of values
Nächstes Thema: Optimize this!