From: | Antonio Fiol Bonnín <fiol(at)w3ping(dot)com> |
---|---|
To: | Francisco Reyes <lists(at)natserv(dot)com> |
Cc: | Javier Dussaillant <ashkar(at)vrweb(dot)cl>, pgsql General List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Select .. Having vs computer fields |
Date: | 2001-12-13 15:37:25 |
Message-ID: | 3C18CB35.8070209@w3ping.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Francisco Reyes wrote:
>On Wed, 12 Dec 2001, Javier Dussaillant wrote:
>
>>At 12:54 PM 12/12/2001 -0500, Francisco Reyes wrote:
>>
>>>Can use use computed fields on the "having" part of select?
>>>I have tried:
>>>select a,b, count(*) as dups_count from some_table having dups_count > 1;
>>>
>>>and it gives me the error "Attribute 'dups_count' not found"
>>>
>>You have to GROUP BY in order to use HAVING. For example:
>>
>>SELECT a,b, count(*) as dups_count FROM some_table GROUP BY a,b HAVING
>>dups_count > 1;
>>
>
>My mistake for not including it in the example. I did use Group By.
>
Rewrite as
SELECT a,b, count(*) as dups_count FROM some_table GROUP BY a,b HAVING
count(*) > 1;
Antonio
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Koenig | 2001-12-13 16:42:14 | How to increase shared mem for PostgreSQL on FreeBSD |
Previous Message | Antonio Fiol Bonnín | 2001-12-13 15:28:41 | Re: slow queries on large syslog table |