Re: Formatting a month in query output

From: "Rodolfo J(dot) Paiz" <rpaiz(at)simpaticus(dot)com>
To: Alexander Borkowski <alexander(dot)borkowski(at)abri(dot)une(dot)edu(dot)au>
Cc: Sean Davis <sdavis2(at)mail(dot)nih(dot)gov>, pgsqlnovice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Formatting a month in query output
Date: 2005-01-27 01:40:09
Message-ID: 1106790009.5295.156.camel@rodolfo.gt.factorrent.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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;
>

flightlog=> 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;

sort_month | month | num | hours
---------------------+----------+-----+-------
2003-08-01 00:00:00 | Aug 2003 | 4 | 5.6
2003-09-01 00:00:00 | Sep 2003 | 2 | 3.5
2003-10-01 00:00:00 | Oct 2003 | 2 | 4.2
2003-11-01 00:00:00 | Nov 2003 | 10 | 17.7
2003-12-01 00:00:00 | Dec 2003 | 10 | 16.4
2004-01-01 00:00:00 | Jan 2004 | 9 | 13.3
2004-02-01 00:00:00 | Feb 2004 | 6 | 9.3
2004-03-01 00:00:00 | Mar 2004 | 10 | 12.2
2004-04-01 00:00:00 | Apr 2004 | 11 | 17.4
2004-05-01 00:00:00 | May 2004 | 5 | 7.3
2004-06-01 00:00:00 | Jun 2004 | 10 | 16.5
2004-07-01 00:00:00 | Jul 2004 | 8 | 10.4
2004-08-01 00:00:00 | Aug 2004 | 8 | 13.0
2004-09-01 00:00:00 | Sep 2004 | 8 | 10.3
2004-10-01 00:00:00 | Oct 2004 | 2 | 2.5
2004-11-01 00:00:00 | Nov 2004 | 10 | 17.4
2004-12-01 00:00:00 | Dec 2004 | 5 | 8.9
2005-01-01 00:00:00 | Jan 2005 | 4 | 6.0
(18 rows)

This would be perfect if we could get rid of that first column and only
display the rest. Is that possible?

Thanks for all the help.

--
Rodolfo J. Paiz <rpaiz(at)simpaticus(dot)com>

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Alexander Borkowski 2005-01-27 02:03:54 Re: Formatting a month in query output
Previous Message Alexander Borkowski 2005-01-27 01:31:44 Re: Formatting a month in query output