From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: inconsistency in aliasing |
Date: | 2009-01-15 10:23:16 |
Message-ID: | gkn2qk$16m$3@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
On 2009-01-14, Louis-David Mitterrand <vindex+lists-pgsql-general(at)apartia(dot)org> wrote:
> Hi,
>
> This works:
>
> critik=# select current_timestamp::abstime::int4 as score order by score;
>
> This doesn't:
>
> critik=# select current_timestamp::abstime::int4 as score order by score + 1;
> ERROR: column "score" does not exist
> LINE 1: ...urrent_timestamp::abstime::int4 as score order by score + 1 ...
>
> Any idea ?
>
> Thanks,
if you really want to do that you can use a subselect,
select score from ( select current_timestamp::abstime::int4 as score )
as foo order by score+1;
but the demonstration is more interesting when the query returns several rows
and the expression changes the order.
select score from ( select generate_series(1,10) as score ) as foo
order by score % 2 desc; -- odds and evens.
:)
bye.
From | Date | Subject | |
---|---|---|---|
Next Message | Grzegorz Jaśkiewicz | 2009-01-15 10:23:34 | Re: inconsistency in aliasing |
Previous Message | Jasen Betts | 2009-01-15 10:14:10 | Re: fire trigger for a row without update? |
From | Date | Subject | |
---|---|---|---|
Next Message | Grzegorz Jaśkiewicz | 2009-01-15 10:23:34 | Re: inconsistency in aliasing |
Previous Message | Jasen Betts | 2009-01-15 10:14:10 | Re: fire trigger for a row without update? |