Re: Ordering YYYY MM DD in reverse chrono order

From: Eric Ridge <ebr(at)tcdi(dot)com>
To: otis_usenet(at)yahoo(dot)com (OtisUsenet)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Ordering YYYY MM DD in reverse chrono order
Date: 2004-04-26 21:30:49
Message-ID: FCC3FDB7-97C8-11D8-A691-000A95BB5944@tcdi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Apr 21, 2004, at 5:19 AM, OtisUsenet wrote:
<snip>

> I am using the following query, but it's not returning dates back in
> the reverse chronological order:

<snip>

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

Maybe I'm missing something, but why not just sort by "uu.add_date
DESC", like so:

ORDER BY uu.add_date DESC;

Seems like it would be more efficient, and there'd be no issues about
forgetting to put DESC after each date_part() (like you have above).

eric

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2004-04-26 22:03:47 Re: Help on "unexpected EOF..client reset by peer" errors
Previous Message Dave Cramer 2004-04-26 20:42:04 Re: [JDBC] loading data into postgresql became slow