Skip site navigation (1) Skip section navigation (2)

Re: Order by YYYY MM DD in reverse chrono order trouble

From: <ogjunk-pgjedan(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Order by YYYY MM DD in reverse chrono order trouble
Date: 2004-04-22 13:37:09
Message-ID: 20040422133709.27730.qmail@web12704.mail.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hello,

Hm, doesn't work for me:

me(at)[local] mydb=> select distinct date_part('year',  uu.add_date), 
date_part('month', uu.add_date),  date_part('day',
uu.add_date)  from uus  inner join ui on uus.user_id=ui.id  inner join 
uu on ui.id=uu.user_id where uus.subscriber_user_id=1 order by
uu.add_date desc;

ERROR:  For SELECT DISTINCT, ORDER BY expressions must appear in target
list

I have this version of PostgreSQL installed: postgresql-7.3.4-3.rhl9

Thanks,
Otis


--- Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> <ogjunk-pgjedan(at)yahoo(dot)com> writes:
> > I'd love to be able to do that, but I cannot just ORDER BY
> uu.add_date,
> > because I do not have uu.add_date in the SELECT part of the
> statement. 
> 
> Sure you can.  Back around SQL89 there was a restriction that ORDER
> BY
> values had to appear in the SELECT list as well, but no modern
> database
> has such a restriction anymore ...
> 
> 			regards, tom lane


In response to

pgsql-sql by date

Next:From: Rod TaylorDate: 2004-04-22 13:58:18
Subject: Re: Server Side C programming Environment Set up
Previous:From: Tom LaneDate: 2004-04-22 13:01:20
Subject: Re: Order by YYYY MM DD in reverse chrono order trouble

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group