Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best approach
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
00693716
Message ID:
00694042
Views:
12
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
Previous
Reply
Map
View

Click here to load this message in the networking platform