Re: I'm using both window and agg, is this expected sorting behavior? - Mailing list pgsql-general

From Tom Lane
Subject Re: I'm using both window and agg, is this expected sorting behavior?
Date
Msg-id 2600124.1696437176@sss.pgh.pa.us
Whole thread Raw
In response to I'm using both window and agg, is this expected sorting behavior?  (jinser <aimer@purejs.icu>)
List pgsql-general
jinser <aimer@purejs.icu> writes:
> This is what confuses me, I've tried many versions of pgsql, at least
> including 11-16, and the behavior is consistent with the above; but I
> feel that maybe the order by in the window function should not affect
> the final result.

Since you have not specified an ORDER BY for the overall query
result, the implementation is entitled to return the rows in
any order it pleases.  Ours happens to sort by the window ordering
before computing the window functions, so that's what you get.
In this case anyway --- you shouldn't rely on that.

            regards, tom lane



pgsql-general by date:

Previous
From: jinser
Date:
Subject: I'm using both window and agg, is this expected sorting behavior?
Next
From: Tom Lane
Date:
Subject: Re: Strategies for converting UTC data to local windows for arbitrary resolutions and timezones