Re: [Question] Window Function Results without ORDER BY Clause

David G. Johnston <david.g.johnston@gmail.com>

From: "David G. Johnston" <david.g.johnston@gmail.com>
To: Zhang Mingli <zmlpostgres@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-11T13:27:45Z
Lists: pgsql-hackers
On Friday, July 11, 2025, Zhang Mingli <zmlpostgres@gmail.com> wrote:

>
> Referring to the SQL 2011 standard, it states that if ORDER BY is
> omitted, the order of rows in the partition is undefined.
> While using a window function without ORDER BY is valid, the resulting
> output seems unpredictable.
>
> So, are both result sets technically correct given the absence of an ORDER
> BY clause?
>

The system is behaving within the requirements of the specification.  The
query itself is bugged code that the query author should fix.

David J.