Search Postgresql Archives

Re: Query help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/1/19 12:05 PM, David G. Johnston wrote:
On Tuesday, January 1, 2019, Adrian Klaver <adrian.klaver@xxxxxxxxxxx <mailto:adrian.klaver@xxxxxxxxxxx>> 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.

Hmm, guess I should spend more time reading the SELECT docs:)


David J.


--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux