Re: Proposal: QUALIFY clause

Marcos Pegoraro <marcos@f10.com.br>

From: Marcos Pegoraro <marcos@f10.com.br>
To: Matheus Alcantara <matheusssilv97@gmail.com>
Cc: Vik Fearing <vik@postgresfriends.org>, Pg Hackers <pgsql-hackers@postgresql.org>, Peter Eisentraut <peter@eisentraut.org>
Date: 2025-07-22T18:11:11Z
Lists: pgsql-hackers
Em ter., 22 de jul. de 2025 às 08:56, Matheus Alcantara <
matheusssilv97@gmail.com> escreveu:

> The current patch supports the following syntaxes:
>     SELECT a, b, c
>     wf() OVER () as d
>     FROM tab
>     QUALIFY d = 1
> When using the "QUALIFY d = 1" form, I currently rewrite the expression
> as "wf() OVER () = 1" by searching the targetlist for the matching
> alias, replacing the Var with the corresponding WindowFunc.
>

Not related to $subject but that way you did,
that replacement alias for wf expression, is cool.
With that would it be possible to have where replacements too ? Maybe.

select a+b as ab from t where ab = 5

regards
Marcos