Re: Formatting a month in query output - Mailing list pgsql-novice

From Alexander Borkowski
Subject Re: Formatting a month in query output
Date
Msg-id 41F84C0A.1080008@abri.une.edu.au
Whole thread Raw
In response to Re: Formatting a month in query output  ("Rodolfo J. Paiz" <rpaiz@simpaticus.com>)
List 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 by date:

Previous
From: "Rodolfo J. Paiz"
Date:
Subject: Re: Formatting a month in query output
Next
From: Bruno Wolff III
Date:
Subject: Re: Two copies of every mail!