Re: Sorting distinct dates by year and month respectively
От | Richard Broersma Jr |
---|---|
Тема | Re: Sorting distinct dates by year and month respectively |
Дата | |
Msg-id | 20060607150138.12804.qmail@web31815.mail.mud.yahoo.com обсуждение исходный текст |
Ответ на | Sorting distinct dates by year and month respectively ("Matt Arnilo S. Baluyos (Mailing Lists)" <matt.baluyos.lists@gmail.com>) |
Ответы |
Re: Sorting distinct dates by year and month respectively
|
Список | 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 по дате отправления: