Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Query on previous row value
Well, assuming the date span can't be more than 24 hours...
select to_char(t_date, 'HH24:MI:SS'),
to_char(to_date('01-jan-1900', 'dd-mon-yyyy')
+ (t_date - lag(t_date, 1) over (order by t_date))
, 'HH24:MI:SS')
from x
Richard
Jeff Pope wrote:
>
> Here's my problem. I need to generate a query that will display a date
> field then the computed time lapse from the queries' previous row.
>
> T_DATE
> -------
> 11:34:17
> 11:35:32
> 11:42:32
>
> I need to display
>
> T_DATE TIME_LAPSE
> ------- --------
> 11:34:17 (null)
> 11:35:32 00:01:15
> 11:42:32 00:07:00
>
> Please advise. Thanks
>
> Jeff
Received on Fri Apr 12 2002 - 15:30:10 CDT
![]() |
![]() |