Re: [SQL] sum-function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [SQL] sum-function
Дата
Msg-id 1537.940696920@sss.pgh.pa.us
обсуждение исходный текст
Список pgsql-sql
guenther@laokoon.IN-Berlin.DE (Christian Guenther) writes:
> SELECT (sum(case when dict.word = 'museum' then 1 else 0 end)) as qu, 
> dict.url_id FROM dict, url
>              WHERE url.rec_id = dict.url_id
>                    AND url.url LIKE '%%'
>                    AND dict.word in ('museum')
>              GROUP BY dict.url_id
>         having qu > 0
> The Problem is qu, I cannot use it for the having.

Neither WHERE nor HAVING pay any attention to column labels; they
work on original attributes.  (Only GROUP BY and ORDER BY accept
column labels as substitutes for real expressions.)  You'll need
to repeat the sum() expression in HAVING, I'm afraid.
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Can VACUUM, but cannot do VACUUM ANALYZE
Следующее
От: "Albert REINER"
Дата:
Сообщение: Re: [SQL] Can VACUUM, but cannot do VACUUM ANALYZE