Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: possible to do a group by on a time interval? (or some other way to do this)

Re: possible to do a group by on a time interval? (or some other way to do this)

From: William Robertson <william_at_williamrobertson.net>
Date: Sat, 13 Oct 2007 18:51:36 +0100
Message-ID: <471105A8.60404@williamrobertson.net>


Maybe something like:

SELECT FLOOR(EXTRACT(minute FROM mytimestamp) / 15)*15 AS period

    , COUNT(*)
FROM metrictable
GROUP BY FLOOR(EXTRACT(minute FROM mytimestamp) / 15)*15

-----Original message-----
From: ryan_gaffuri_at_comcast.net
Date: 10/10/07 23:11
> seselect max(mytimestamp) as time, sum(mymetric) as bytes
> from metrictable
> where mymetric > ( select max(mymetric) from metrictable) - (1/96)
>
>
> "mytimestamp" is a timestamp data type.
>
> I want to get a sum for every 15 minute interval in the table. I will add a where clause to limit how far back I want to go. The where clause I have there now is just an example.
>
> tried group by, group by rollup, analytic with a window.
>
> do i need the model clause? I have never used that. I really do think there is a way to do this in straight sql. Been working on it for a while....
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>
>

--
http://www.freelists.org/webpage/oracle-l
Received on Sat Oct 13 2007 - 12:51:36 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US