Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Statement Help
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00602593
Message ID:
00602599
Vues:
17
This message has been marked as the solution to the initial question of the thread.
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.
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform