Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column

From: Jochen Erwied <jochen(at)pgsql-performance(dot)erwied(dot)eu>
To: Dave Crooke <dcrooke(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Possible parser bug? .... Re: Picking out the most recent row using a time stamp column
Date: 2011-02-25 00:03:12
Message-ID: 1923741490.20110225010312@erwied.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Friday, February 25, 2011, 12:53:08 AM you wrote:

> select distinct on (a, b, c)
> a, b c, time_stamp, value

Without the comma, you declare 'b AS c'

> from data
> order by a, b, c, time_stamp desc;

> The output produced is the same as this query:

> select distinct on (a, b)
> a, b, time_stamp, value
> from data
> order by a, b, time_stamp desc;

the 'c' is optimized away, since it is an alias for b, and thus redundant
for the distinct.

> Not sure if this is considered a parser bug or not, but it feels slightly
> odd not to get an error.

No error, just plain SQL :-)

--
Jochen Erwied | home: jochen(at)erwied(dot)eu +49-208-38800-18, FAX: -19
Sauerbruchstr. 17 | work: joe(at)mbs-software(dot)de +49-2151-7294-24, FAX: -50
D-45470 Muelheim | mobile: jochen(dot)erwied(at)vodafone(dot)de +49-173-5404164

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2011-02-25 00:20:00 Re: Picking out the most recent row using a time stamp column
Previous Message Dave Crooke 2011-02-24 23:53:08 Possible parser bug? .... Re: Picking out the most recent row using a time stamp column