Re: inconsistency in aliasing

From: Lennin Caro <lennin(dot)caro(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org, Louis-David Mitterrand <vindex+lists-pgsql-general(at)apartia(dot)org>
Subject: Re: inconsistency in aliasing
Date: 2009-01-14 13:53:57
Message-ID: 251719.28928.qm@web59504.mail.ac4.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

--- On Wed, 1/14/09, Louis-David Mitterrand <vindex+lists-pgsql-general(at)apartia(dot)org> wrote:

> From: Louis-David Mitterrand <vindex+lists-pgsql-general(at)apartia(dot)org>
> Subject: Re: [GENERAL] inconsistency in aliasing
> To: pgsql-general(at)postgresql(dot)org
> Date: Wednesday, January 14, 2009, 11:27 AM
> On Wed, Jan 14, 2009 at 12:06:47PM +0100, A. Kretschmer
> wrote:
> > In response to Louis-David Mitterrand :
> > > 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 ?
> >
> > Yes, you can't use the alias in the ORDER BY. Use
> the real column-name.
> >
> > select current_timestamp::abstime::int4 as score order
> by
> > current_timestamp::abstime::int4;
>
> Did you try
>
> "select current_timestamp::abstime::int4 as score
> order by score;" ?
>
> This seems to be an "order by <alias>"
>
> --
> http://www.critikart.net
>

you can't use operator in the group by, try this

select score,score+1 as score2 from (
select current_timestamp::abstime::int4 as score)
order by score2

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2009-01-14 13:59:41 Re: simple limit of decimals
Previous Message Richard Huxton 2009-01-14 13:32:40 Re: Strange invalid constrain problem with PostgreSQL 8.3.1

Browse pgsql-hackers by date

  From Date Subject
Next Message Louis-David Mitterrand 2009-01-14 14:01:35 Re: inconsistency in aliasing
Previous Message Daniel Verite 2009-01-14 12:07:51 Re: inconsistency in aliasing