pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ogjunk-pgjedan@yahoo.com
To: pgsql-sql@postgresql.org
Subject: Re: Order by YYYY MM DD in reverse chrono order trouble
Date: Thu, 22 Apr 2004 06:37:09 -0700 (PDT)
Message-ID: <20040422133709.27730.qmail@web12704.mail.yahoo.com> (raw)
In-Reply-To: <25337.1082638880@sss.pgh.pa.us>

Hello,

Hm, doesn't work for me:

me@[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@sss.pgh.pa.us> wrote:
> <ogjunk-pgjedan@yahoo.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




view thread (12+ messages)  latest in thread

Message-ID: <20040422133709.27730.qmail@web12704.mail.yahoo.com>
Permalink:  ../20040422133709.27730.qmail@web12704.mail.yahoo.com/
Also on:    postgresql.org/message-id/20040422133709.27730.qmail@web12704.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ogjunk-pgjedan@yahoo.com
  Subject: Re: Order by YYYY MM DD in reverse chrono order trouble
  In-Reply-To: <20040422133709.27730.qmail@web12704.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox