Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Summary the data according to the time
<lily99_at_my-deja.com> wrote in message news:7qp3hk$pv1$1_at_nnrp1.deja.com...
> Hi,
> I have a log table which has file_size and date/time
> fields. I want to summary file_size based on every ten
> minutes. I read some Oracle books, but still cannot figure
> out how I can do this. Can someone help me with this issue?
> Thanks you very very much.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
It's a interesting question.
Since the built-in function can not perform truncate a date datatype to 10 minutes,
It needs a trick to do, like the following:
select trunc(sysdate)+floor((datetime-trunc(sysdate))*144)/144, sum(file_size)
from log_table
group by trunc(sysdate)+floor((datetime-trunc(sysdate))*144)/144;
The result will look like:
TRUNC(SYSDATE)+TRUN SUM(FILE_SIZE)
------------------- -------------- 1999/09/04 06:00:00 91 1999/09/04 06:10:00 344 1999/09/04 06:20:00 600 1999/09/04 06:30:00 856 1999/09/04 06:40:00 1112 1999/09/04 06:50:00 1368 1999/09/04 07:00:00 679Received on Sat Sep 04 1999 - 12:15:46 CDT
![]() |
![]() |