Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best approach
Message
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Best approach
Divers
Thread ID:
00693716
Message ID:
00693716
Vues:
57
The query below returns the basic information I need to work with. It 1 record for each completed case. What I need to add is the time difference between when a patient exits a room until the next patient enters the same room. These fields are based on enteror and exitor. I don't know if I can somehow code a subquery to return this field, or if I'm going to have to do sometype of cursor.
SELECT TOP 100 PERCENT dbo.corooms.roomid,dbo.corooms.roomname, dbo.coper.lastname, 
       dbo.coper.firstname, dbo.meetproc.description, dbo.meetings.enteror, 
       dbo.meetings.exitor, dbo.meetings.procstart, dbo.meetings.procend, 
       dbo.meetings.begintime, dbo.corooms.schedfrom, dbo.corooms.schedto
FROM   dbo.meetings INNER JOIN
       dbo.meetproc ON dbo.meetings.meetingnumber = dbo.meetproc.meetingnumber INNER JOIN
       dbo.corooms ON dbo.meetings.roomid = dbo.corooms.roomid INNER JOIN
       dbo.coper ON dbo.meetproc.coperid = dbo.coper.coperid
WHERE     (dbo.meetings.iscompleted = 1) AND (dbo.meetings.deptid = 1)
ORDER BY dbo.meetings.enteror, dbo.corooms.roomname
Example Data:
ROOMID, ROOM NAME,  ENTER OR,  EXIT OR   NEXT PT IN   DIFF.
------------------------------------------------------------
  1      OR 1        07:00      08:30     09:00         30
  1      OR 1        09:30      10:00     10:45         45
  1      OR 1        10:45      13:45     

  2      OR 2        07:00      09:45     10:00         15
  2      OR 2        10:00      15:00    
Thanks
Kirk
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform