Re: Ordering YYYY MM DD in reverse chrono order

From: Holger Klawitter <lists(at)klawitter(dot)de>
To: otis_usenet(at)yahoo(dot)com (OtisUsenet), pgsql-general(at)postgresql(dot)org
Subject: Re: Ordering YYYY MM DD in reverse chrono order
Date: 2004-04-26 16:39:28
Message-ID: 200404261839.33155.lists@klawitter.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> ORDER BY
> date_part('year', uu.add_date), date_part('month', uu.add_date),
> date_part('day', uu.add_date) DESC;

You are sorting by three columns, only the last one is desc.

What you need is:

...
order by
date_part( 'year', uu.add_date ) desc,
date_part( 'month', uu.add_date ) desc,
date_part( 'day', uu.add_date ) desc
;

Mit freundlichem Gruß / With kind regards
Holger Klawitter
- --
lists <at> klawitter <dot> de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFAjTtF1Xdt0HKSwgYRAmaDAKCcSo5kEPkn4QJfsFhg9EE0k/dmmwCfa7gB
cUjzCy/X0mJXW0Aooyb7pbE=
=0Fhk
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2004-04-26 16:51:07 Re: PostgreSQL 7.4.2 initdb problem
Previous Message Christopher Browne 2004-04-26 16:27:39 Re: newsbie: ORDBMS vs RDBMS