| From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
|---|---|
| To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
| Cc: | John W Higgins <wishdev(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Query help |
| Date: | 2019-01-01 20:05:41 |
| Message-ID: | CAKFQuwZ=YT0AaNR94er-LmVb_4Oj0q_KyX=eUsD7usWEAg00SQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Tuesday, January 1, 2019, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:
> On 1/1/19 11:26 AM, John W Higgins wrote:
>>
>> with accounts_over_total as (
>> select accountid from transactions where sum(amount) >= 50 group by
>> accountid)
>>
>
> Unfortunately there is a hitch in the above:(
>
> select p_item_no from projection where sum(qty) > 100 group by(p_item_no);
> ERROR: aggregate functions are not allowed in WHERE
>
Which is where the HAVING clause comes in. It filters out groups based on
an expression containing an aggregate function.
David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Brent Wood | 2019-01-01 20:53:45 | Re: Relocatable Binaries (RPMs) : custom installation path for PostgreSQL |
| Previous Message | Adrian Klaver | 2019-01-01 19:44:03 | Re: Query help |