From: Tom Lane <tgl@sss.pgh.pa.us>
To: guenther@laokoon.IN-Berlin.DE
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] sum-function
Date: Sat, 23 Oct 1999 12:42:00 -0400
Message-ID: <1537.940696920@sss.pgh.pa.us> (raw)
In-Reply-To: <199910231305.PAA31741@laokoon.bug.net>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, guenther@laokoon.IN-Berlin.DE
Subject: Re: [SQL] sum-function
In-Reply-To: <1537.940696920@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox