Here's the straight forward answer.
SELECT
meetingnumber,
DATEDIFF(minute, begintime, endtime) AS totalblocktime,
(
SELECT
SUM(DATEDIFF(minute, begintime, endtime)
FROM
meeting m1
WHERE
m1.blockid = meeting.meetingnumber) AS totalblocktimeused
FROM
meetings
WHERE
isblock = 1
-Mike
>Meetings table contains scheduled appoints that are stand-alone and also block appoints (a block can contain multiple appointments)
>
>key fields
>
>meetingnumber begintime endtime isblock blockmember blockid
> unique int dt dt bit bit int
>===============================================================================
>
>
>A standalone appointment gets a unique meetingnumber, begintime,endtime, isblock=0,blockmember=0 and blockid=0
>
>A block get a unique meetingnumber, begintime,endtime,isblock = 1, blockmember=0, and blockid=0
>
>An appointment inside a block get a unique meetingnumber, begintime,endtime, isblock=0, blockmember=1 and blockid=meetingnumber of the block
>
>I need a sql statement that would return a meetingnumber of the block, the total blocktime (endtime-begintime) of the block, and the totalblocktimeused.
>
>The total blocktime used would consists of adding up the endtime-begintime of all the appointsment assigned to a block.