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

Home -> Community -> Usenet -> c.d.o.server -> Re: Calculating Total Time

Re: Calculating Total Time

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Mon, 29 Jul 2002 20:29:33 GMT
Message-ID: <3D45A561.71D341D4@exesolutions.com>


Scotty wrote:

> Hello all....
>
> I need a little PL/SQL help.
>
> I have at simple table
>
> Timestamp Asset Status
> 2002-07-01 12:00 Pump 1 OPEN
> 2002-07-01 2:00 Pump 1 CLOSED
> 2002-07-01 3:30 Pump 1 OPEN
> 2002-07-01 3:45 Pump 1 CLOSED
> 2002-07-02 15:45 Pump 1 OPEN
> 2002-07-02 18:15 Pump 1 CLOSED
> .
> .
> .
> You get the idea.
>
> I would like to calculate the total time Pump 1 was OPEN and total
> time Pump 1 was closed for a given starting time period and ending
> time period.
>
> Is this what Time Series is good for? Or is there an straight PL/SQL
> algorithm I can use?
>
> Thanks.

I would create a static cursor that has an orderby on the Timestamp and as you loop through the records record the open and closed time as accumulations in separate variables.

Daniel Morgan Received on Mon Jul 29 2002 - 15:29:33 CDT

Original text of this message

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