Re: [Question] Window Function Results without ORDER BY Clause - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: [Question] Window Function Results without ORDER BY Clause
Date
Msg-id CAKFQuwZE-6ezOJprZeMgDFLUU79kD_x+4_Qh90_WT=ekJcrEaw@mail.gmail.com
Whole thread Raw
In response to [Question] Window Function Results without ORDER BY Clause  (Zhang Mingli <zmlpostgres@gmail.com>)
Responses Re: [Question] Window Function Results without ORDER BY Clause
List 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.

pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: amcheck: support for GiST
Next
From: Andrei Lepikhov
Date:
Subject: Re: track needed attributes in plan nodes for executor use