Hi,
I didn't read the whole article, but had a couple on the more basic points.
SELECT
COUNT(*)
FROM
[MY_EVENTS]
WHERE
---CASES 3, 4 AND 5
(([STARTING_TIME] > 7/1/2007 12:00 PM AND [STARTING_TIME] < 7/1/2007 1:00 PM)
OR ([ENDING_TIME] > 7/1/2007 12:00 PM AND [ENDING_TIME] < 7/1/2007 1:00 PM))
OR
---CASE 2
([STARTING_TIME] < 7/1/2007 12:00 PM AND [ENDING_TIME] > 7/1/2007 1:00 PM)
This could be written much more simply as
SELECT
COUNT(*)
FROM
[MY_EVENTS]
WHERE [STARTING_TIME] <= 7/1/2007 1:00 PM
AND [ENDING_TIME] >= 7/1/2007 12:00 PM --This assumes that starting_time<ending_time
Also to get the time period utilised for each row you could do something like
(((7/1/2007 1:00PM)-(START_TIME)-(CASE END_TIME<(7/1/2007 1:00PM) THEN ((7/1/2007 1:00PM)-(END_TIME)) ELSE 0))%60)*24*60
to get the number of minutes
Not criticising, it's just what I thought of what I began, and couldn't continue until I wrote it down