Re: different results using count(x)

Поиск
Список
Период
Сортировка
От Raimon Fernandez
Тема Re: different results using count(x)
Дата
Msg-id CB64D06A-20B4-4B23-8366-F1C7A46989A2@montx.com
обсуждение исходный текст
Ответ на different results using count(x)  (Raimon Fernandez <coder@montx.com>)
Список pgsql-novice
On 09/09/2009, at 8:34, Raimon Fernandez wrote:

> Hello,
>
>
> What's the difference between:
>
> SELECT count(id) FROM scanns WHERE tipus='esc'; => 11235
> SELECT count(pages) FROM scanns WHERE tipus='esc'; => 11165
> SELECT count(*) FROM scanns WHERE tipus='esc'; => 11235
>
> Why are some rows that aren't included in the count(pages) SELECT ?
>
> There are not NULL values in the pages field:
>
> SELECT count(pages) FROM scanns WHERE tipus='esc' AND pages IS NOT
> NULL; => 11165
> SELECT count(pages) FROM scanns WHERE tipus='esc' AND pages IS NULL;
> => 0
>
> And I think the three SELECTS should return the same rows number ...
>
>
> thanks for your help,
>
> r.

ok, I found the problem ...

this is wrong:

SELECT count(pages) FROM scanns WHERE tipus='esc' AND pages IS NULL;
=> 0


this is the correct:

SELECT count(*) FROM scanns WHERE tipus='esc' AND pages IS NULL; => 70


thanks,


raimon


В списке pgsql-novice по дате отправления:

Предыдущее
От: Raimon Fernandez
Дата:
Сообщение: different results using count(x)
Следующее
От: Sergey Samokhin
Дата:
Сообщение: Re: Can't understand how a query from the documentation works