pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tim Landscheidt <tim@tim-landscheidt.de>
To: pgsql-sql@postgresql.org
Subject: Re: Lag and lead window functions order by weirdness
Date: Sun, 18 Oct 2009 16:51:38 +0000
Message-ID: <m31vl0r6g5.fsf@passepartout.tim-landscheidt.de> (raw)
References: <bddc86150910091726s704277f9u7ddcead9874889b3@mail.gmail.com>
	<bddc86150910120009p3ae9d578x2dac139a71e4d045@mail.gmail.com>

Thom Brown <thombrown@gmail.com> wrote:

> [...]
> Having a look around, it looks as if Postgres might be misbehaving.
>  According to this page,
> http://my.safaribooksonline.com/0596004818/sqlnut2-CHP-4-SECT-3, the ORDER
> BY in the window function's clause shouldn't be having this ordering effect:

> "Furthermore, the order within these groups is defined by an ordering
> clause, but that order only affects function evaluation, and has no effect
> on the order in which rows are returned by the query."

> The behaviour is unexpected from my perspective, but obviously there are
> workarounds.  Is anyone able to confirm any of this?

AFAIR, others have already pointed out that without an "OR-
DER BY" clause PostgreSQL can return the result set in *any*
"order" it deems fit. So why don't you use one?

Tim




view thread (2+ messages)

Message-ID: <m31vl0r6g5.fsf@passepartout.tim-landscheidt.de>
Permalink:  ../m31vl0r6g5.fsf@passepartout.tim-landscheidt.de/
Also on:    postgresql.org/message-id/m31vl0r6g5.fsf@passepartout.tim-landscheidt.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tim@tim-landscheidt.de
  Subject: Re: Lag and lead window functions order by weirdness
  In-Reply-To: <m31vl0r6g5.fsf@passepartout.tim-landscheidt.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox