From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Matt Arnilo S(dot) Baluyos (Mailing Lists)" <matt(dot)baluyos(dot)lists(at)gmail(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Sorting distinct dates by year and month respectively |
Date: | 2006-06-07 14:56:20 |
Message-ID: | 29995.1149692180@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
"Matt Arnilo S. Baluyos (Mailing Lists)" <matt(dot)baluyos(dot)lists(at)gmail(dot)com> writes:
> ... ORDER BY date_part('year', article_pubdate),
> date_part('month', article_pubdate) DESC;
The above means
... ORDER BY date_part('year', article_pubdate) ASC,
date_part('month', article_pubdate) DESC;
You want
... ORDER BY date_part('year', article_pubdate) DESC,
date_part('month', article_pubdate) DESC;
As noted by the other respondent, sorting on one date_trunc column is
probably the better way to do it, but I thought I'd point out the DESC
issue anyway. A lot of people get that wrong.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Broersma Jr | 2006-06-07 15:01:38 | Re: Sorting distinct dates by year and month respectively |
Previous Message | Greg | 2006-06-07 13:35:35 | Can PostGreSQL slow down a Windows PC much? |