Re: Formatting a month in query output
От | Alexander Borkowski |
---|---|
Тема | Re: Formatting a month in query output |
Дата | |
Msg-id | 41F84C0A.1080008@abri.une.edu.au обсуждение исходный текст |
Ответ на | Re: Formatting a month in query output ("Rodolfo J. Paiz" <rpaiz@simpaticus.com>) |
Список | pgsql-novice |
Rodolfo J. Paiz wrote: > On Thu, 2005-01-27 at 12:31 +1100, Alexander Borkowski wrote: > >>Sorry, I totally missed the crucial point there. How about >> >>select date_trunc('month', date) as sort_month, to_char(date,'Mon YYYY') >>as month, count(num) as num, sum(hrs_total) as hours from flights group >>by sort_month, month order by sort_month asc; [...] > This would be perfect if we could get rid of that first column and only > display the rest. Is that possible? Apart from just not displaying it on the client side you can do a subselect. For example: select to_char(monthly_flights.sort_month, 'Mon YYYY') as month, monthly_flights.num, monthly_flights.hours from ( select date_trunc('month', date) as sort_month, count(num) as num, sum(hrs_total) as hours from flights group by sort_month ) as monthly_flights order by monthly_flights.sort_month asc; Cheers, Alex
В списке pgsql-novice по дате отправления: