HAVING <alias> ...

From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: HAVING <alias> ...
Date: 2005-04-20 14:23:02
Message-ID: 20050420112055.V76866@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Is there a reason (other then it hasn't been implemented yet?) that the
following couldn't work?

SELECT id,count(id) AS cnt
FROM table
WHERE id IN ( 1,2,3,4,5)
GROUP BY id
HAVING cnt = 2;

instead of:

SELECT id,count(id) AS cnt
FROM table
WHERE id IN ( 1,2,3,4,5)
GROUP BY id
HAVING count(id) = 2;

The second one would have to 're-run' the COUNT against the table, would
it not? Whereas the first would take the existing results?

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephan Szabo 2005-04-20 14:26:18 Re: Foreign keys on array elements
Previous Message Simon Riggs 2005-04-20 12:57:59 Re: Problem with PITR recovery