Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best approach
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Divers
Thread ID:
00693716
Message ID:
00694042
Vues:
13
This message has been marked as the solution to the initial question of the thread.
You can do a select statment as part of the list of fields so something like this should work.
SELECT c.roomid, c.roomname, m.enteror, m.exitor, (select top 1 m2.enteror as nextptin from 
                                                    FROM  dbo.meetings m2 INNER JOIN dbo.corooms c2 ON m2.roomid = c2.roomid 
                                                    where c2.roomid = c1.roomid and m2.enteror > m1.exitor
                                                    order by m2.enteror) as nextptin,

                                                   m.exitor - (select top 1 m2.enteror as nextptin from 
                                                    FROM  dbo.meetings m2 INNER JOIN dbo.corooms c2 ON m2.roomid = c2.roomid 
                                                    where c2.roomid = c1.roomid and m2.enteror > m1.exitor
                                                    order by m2.enteror) as diff
FROM   dbo.meetings m INNER JOIN
       dbo.corooms c ON m.roomid = c.roomid 
WHERE     (dbo.meetings.iscompleted = 1) AND (dbo.meetings.deptid = 1)
ORDER BY dbo.meetings.enteror, dbo.corooms.roomname
Of course this is untested. You probably going to have to wait till Sergy looks at it to get a solid answer.
HTH,
Eric Stephani
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform