List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 12 2003 5:09pm
Subject:Re: Counting null values
View as plain text  
At 9:41 +0200 2/12/03, Octavian Rasnita wrote:
>It won't work because MySQL doesn't count null values.

It depends.

count(FieldName) will not count NULL values
count(*) will, because it counts rows, not values.

>
>Teddy,
>Teddy's Center: http://teddy.fcc.ro/
>Email: orasnita@stripped
>
>----- Original Message -----
>From: "Daniel Kiss" <niel@stripped>
>To: <mysql@stripped>
>Sent: Tuesday, February 11, 2003 8:18 AM
>Subject: Re: Counting null values
>
>
>Hi Octavian,
>
>Try this:
>
>select FieldName, count(*) from TableName group by FieldName
>
>Bye,
>          Danny
>
>At 16:39 2003.02.08._+0200, you wrote:
>>Hi all,
>>
>>I have a table where I have something like this:
>>
>>| abc |
>>| abc |
>>| xxx |
>>| null |
>>| null |
>>| null |
>>
>>I want to count these lines to give the result 5, meaning a distinct count
>>for values which are not null, and counting all the null values.
>>
>>This means 1 for "abc", one for "xxx", and 3 for null values.
>>
>>Can you tell me what sql query should I use for counting this?
>>
>>Thank you.
>>
>>
>>Teddy,
>>Teddy's Center: http://teddy.fcc.ro/
>  >Email: orasnita@stripped


Thread
Counting null valuesOctavian Rasnita9 Feb
  • Re: Counting null valuesDaniel Kiss11 Feb
    • Re: Counting null valuesOctavian Rasnita12 Feb
      • Re: Counting null valuesPaul DuBois12 Feb
    • Re: Counting null valuesOctavian Rasnita13 Feb