X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 97A1FD1BB16 for ; Fri, 23 Apr 2004 04:15:28 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 94137-06 for ; Fri, 23 Apr 2004 04:15:26 -0300 (ADT) Received: from mail.cobweb.nl (mx1.cobweb.nl [80.242.96.4]) by svr1.postgresql.org (Postfix) with ESMTP id C5A63D1BA9F for ; Fri, 23 Apr 2004 04:15:23 -0300 (ADT) Received: from farcourier.com (dp3-26.dsl.cobweb.nl [193.67.120.154] (may be forged)) by mail.cobweb.nl (8.12.8/8.12.7) with ESMTP id i3N7FSEx042463 for ; Fri, 23 Apr 2004 09:15:29 +0200 (CEST) (envelope-from s.vanroye@farcourier.com) MIME-Version: 1.0 Subject: Re: Order by YYYY MM DD in reverse chrono order trouble Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Fri, 23 Apr 2004 09:14:55 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 content-class: urn:content-classes:message Message-ID: <71E201BE5E881C46811BA160694C5FCB0FA93A@fs1000.farcourier.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] Order by YYYY MM DD in reverse chrono order trouble Thread-Index: AcQogSRk89bU2N3ESFm+EIicYiuFGgAgPMkQ From: "Stijn Vanroye" To: Cc: X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/247 X-Sequence-Number: 17622 Indeed, it seems that I get the same result for a similar query. I'm running version 7.3.4 on a rh 9 server. Also: is the function date_part a function you wrote yourself? I get an err= or stating that the function date_part("Unknown",date) is not recognized. It maybe not a solution to the actual problem but you could try this: save the date and the time in two seperate fields. I use a similar construc= tion for convenience. Regards, Stijn. =20 > Hello, >=20 > Hm, doesn't work for me: >=20 > me@[local] mydb=3D> select distinct date_part('year', uu.add_date),=20 > date_part('month', uu.add_date), date_part('day', > uu.add_date) from uus inner join ui on uus.user_id=3Dui.id=20=20 > inner join=20 > uu on ui.id=3Duu.user_id where uus.subscriber_user_id=3D1 order by > uu.add_date desc; >=20 > ERROR: For SELECT DISTINCT, ORDER BY expressions must appear=20 > in target > list >=20 > I have this version of PostgreSQL installed: postgresql-7.3.4-3.rhl9 >=20 > Thanks, > Otis >=20 >=20 > --- Tom Lane wrote: > > 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.=20 > >=20 > > 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 ... > >=20 > > regards, tom lane >=20 >=20 > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? >=20 > http://www.postgresql.org/docs/faqs/FAQ.html >=20