Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Most efficient Limited select join
Message
From
16/06/2005 14:15:40
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
16/06/2005 09:51:57
General information
Forum:
Microsoft SQL Server
Category:
Database design
Miscellaneous
Thread ID:
01023931
Message ID:
01024071
Views:
21
This message has been marked as the solution to the initial question of the thread.
>I have tblLocation as a child table of tblItem. Any item may have several locations over time. I am trying to find the most efficient method of listing all items with only the last location. Any and all help is appreciated.
SELECT i.ItemID, l.LocationID
FROM tblItem i
     INNER JOIN tblLocation l
          ON i.ItemID = l.ItemID
              AND l.timestamp = (SELECT MAX(timestamp) 
                                 FROM tblLocation 
                                 WHERE ItemID = i.ItemID)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform