Re: Sorting distinct dates by year and month respectively - Mailing list pgsql-novice

From Richard Broersma Jr
Subject Re: Sorting distinct dates by year and month respectively
Date
Msg-id 20060607150138.12804.qmail@web31815.mail.mud.yahoo.com
Whole thread Raw
In response to Sorting distinct dates by year and month respectively  ("Matt Arnilo S. Baluyos (Mailing Lists)" <matt.baluyos.lists@gmail.com>)
Responses Re: Sorting distinct dates by year and month respectively  ("Matt Arnilo S. Baluyos (Mailing Lists)" <matt.baluyos.lists@gmail.com>)
List pgsql-novice
> Now, I'd like to get only the year and month parts but I want them
> ordered by year and then by month in ascending order. I'm using the
> query below, but it doesn't order the results the way I want it.
>
> gsin=> SELECT DISTINCT date_part('year', article_pubdate),
> date_part('month', article_pubdate) FROM articles GROUP BY
> date_part('year', article_pubdate), date_part('month',
> article_pubdate) ORDER BY date_part('year', article_pubdate),
> date_part('month', article_pubdate) DESC;
OOPS,

Sorry,

I previous email, did not really answer your question.

your year column is sorted ascending ( small to great).
your month column is sorted decending ( great to small).

you should specify asc or desc for both columns to insure the desired result.

Regards,

Richard Broersma Jr.


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: Sorting distinct dates by year and month respectively
Next
From: "Matt Arnilo S. Baluyos (Mailing Lists)"
Date:
Subject: Re: Sorting distinct dates by year and month respectively