From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | guenther(at)laokoon(dot)IN-Berlin(dot)DE (Christian Guenther) |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [SQL] sum-function |
Date: | 1999-10-23 16:42:00 |
Message-ID: | 1537.940696920@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
guenther(at)laokoon(dot)IN-Berlin(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Sam O'Connor | 1999-10-23 22:10:58 | BUG in PgODBC found/fixed (win32) |
Previous Message | Tom Lane | 1999-10-23 16:18:33 | Re: [SQL] Can VACUUM, but cannot do VACUUM ANALYZE |