Re: [GENERAL] Question regarding new windowing functions in 8.4devel - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [GENERAL] Question regarding new windowing functions in 8.4devel
Date
Msg-id 8928.1232129126@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] Question regarding new windowing functions in 8.4devel  (David Fetter <david@fetter.org>)
List pgsql-hackers
David Fetter <david@fetter.org> writes:
> Basically, there is no way I've found so far to qualify any window
> function in the target list, which makes a giant POLA violation.

The FM points out in at least two places that window functions logically
execute on the output of the WHERE/GROUP BY/HAVING steps.   It's
conceptually nonsensical to have window function calls in those clauses,
just like it's conceptually nonsensical to use aggregates in WHERE.

Therefore, if you need to filter on the results of the window functions,
you put them into a sub-select and write the filter condition in the
outer query.  This is required by spec, and it really does not matter
whether you find it astonishing.

            regards, tom lane

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: FATAL: could not open relation pg_tblspc/491086/467369/491103: No such file or directory
Next
From: Tom Lane
Date:
Subject: Re: FWD: Re: Updated backslash consistency patch