Re: 7.0.3 and 7.1.3 different results?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: 7.0.3 and 7.1.3 different results?
Дата
Msg-id web-140852@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на 7.0.3 and 7.1.3 different results?  (Joel Mc Graw <jpmcgraw1@home.com>)
Ответы Re: 7.0.3 and 7.1.3 different results?  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-sql
Joel,

> A query such as "select sum(pages) from job_documents where
> delivery_type='print'" returned 0 in version 7.0.3 if there were no
> rows
> matching the query. In 7.1.3 the result is NULL if no rows match the
> query. Why the change? Which result is "correct" according to the
> SQL
> standard?

While I wasn't aware of the change between versions, returning no rows
is correct for any aggregate except COUNT, which returns 0. Although,
now that you mention it, I'm not quite sure why that's the rule. I
mean, shouldn't COUNT return no rows, too?

Goes to show you that the SQL standard isn't even the model of perfect
consistency ....

BTW, returning no rows is somewhat different than returning NULL. WHat
you should be seeing is:

SELECT sum(id) FROM tableA WHERE field2 = 'not found';

sum
------------------

rather than

sum
------------------
NULL


-Josh


Вложения

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

Предыдущее
От: "Jeff Boes"
Дата:
Сообщение: Re: ORDER BY case insensitive?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Question about indexing!