Re: Lag and lead window functions order by weirdness

From: Tim Landscheidt <tim(at)tim-landscheidt(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Lag and lead window functions order by weirdness
Date: 2009-10-18 16:51:38
Message-ID: m31vl0r6g5.fsf@passepartout.tim-landscheidt.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thom Brown <thombrown(at)gmail(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Oliveiros C, 2009-10-19 17:07:57 Re: How to order varchar data by word
Previous Message Rob Sargent 2009-10-18 05:26:56 Re: Efficiency in Multiple Queries of Same Table in a PL/PgSQL Function