Re: Counting Time overlap periods
From: Adam Machanic (amachanic_at_hotmail._removetoemail_.com)
Date: 08/26/04
- Next message: Eric Sabine: "Re: Counting Time overlap periods"
- Previous message: David: "Diff. Execution plan for 2 identical DB"
- In reply to: PRADEEP T.N.: "Counting Time overlap periods"
- Next in thread: Eric Sabine: "Re: Counting Time overlap periods"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Aug 2004 10:24:25 -0400
Would this work for you:
SELECT EventId, DATEDIFF(mi, StartTime, EndTime) AS Duration
FROM
(SELECT EventId, MIN(StartTime) AS StartTime, MAX(EndTime) AS EndTime
FROM YourTable
GROUP BY EventId) AS x (EventId, StartTime, EndTime)
"PRADEEP T.N." <PRADEEP T.N.@discussions.microsoft.com> wrote in message
news:6B0D64DC-F1FA-43BC-8046-EF9CA8B77C70@microsoft.com...
> I have a table, which stores the events occured, like this (starttime &
> endtime are datetime columns)
> StartTime EndTime
> 08:30 08:31
> 08:32 08:35
> 08:02 08:05
> 08:31 08:32
>
> I want to take the duration of the event for a given hour. I cannot take
the
> difference of Max() - Min() because it will include the OVERLAP duration
> also. I want the duration of event without time overlap.
>
> Anybody knows how to achieve this?
>
> Thanks.
>
- Next message: Eric Sabine: "Re: Counting Time overlap periods"
- Previous message: David: "Diff. Execution plan for 2 identical DB"
- In reply to: PRADEEP T.N.: "Counting Time overlap periods"
- Next in thread: Eric Sabine: "Re: Counting Time overlap periods"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|