Re: Seemingly inconsistent ORDER BY behavior

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: Richard Hipp <drh(at)sqlite(dot)org>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Seemingly inconsistent ORDER BY behavior
Date: 2013-08-14 18:50:52
Message-ID: CAOR=d=1US2Vx_FdhYm=sN2g=mXvrF9wb1VwsiX1oW2ru4HZM+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Aug 14, 2013 at 12:31 PM, Richard Hipp <drh(at)sqlite(dot)org> wrote:
>
>
> On Wed, Aug 14, 2013 at 2:28 PM, Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
> wrote:
>>
>> On Wed, Aug 14, 2013 at 12:01 PM, Richard Hipp <drh(at)sqlite(dot)org> wrote:
>>
>> substr(m,2) as m
>>
>> is bad form. Always use a new and unique alias, like m1. How does this
>> work:
>>
>> SELECT '2', substr(m,2) AS m1
>> FROM t1
>> ORDER BY lower(m1);
>
>
> Tnx. I think everybody agrees that "substr(m,2) as m" is bad form. And all
> the database engines get the same consistent answer when you avoid the bad
> form and use "substr(m,2) as m1" instead. The question is, what should the
> database engine do when the programmer disregards sounds advice and uses the
> bad form anyhow?

My guess is that either the SQL spec says it's system determined OR
that the way postgres does it is right. And I'm leaning towards the
second. Someone with the spec hand would have to look it up.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-08-14 18:56:09 Re: Seemingly inconsistent ORDER BY behavior
Previous Message Richard Hipp 2013-08-14 18:31:30 Re: Seemingly inconsistent ORDER BY behavior