Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: group by hour?
On Sun, 13 Apr 1997 11:24:33 +0000, Chrysalis <cellis_at_iol.ie> wrote:
>select to_char(<date_column>,'dd-Mon-yyyy hh24'),avg(temperature)
>from ...
>group by to_char(date_column,'dd-Mon-yyyy hh24');
Better yet:
select to_char(to_date(date_column, 'yyyymmddhh24'), 'mm/dd/yy hh pm')
date_column, avg_temp
from
(
select to_char(<date_column>, 'yyyymmddhh24') date_column,
avg(temprature) avg_temp
from <some_table>
group by to_char(<date_column>, 'yyyymmddhh24')
) v1
;
That way it will come back in proper order, but still be 'human readable' in the customary date & time format. Received on Mon Apr 14 1997 - 00:00:00 CDT