Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Most efficient Limited select join
Message
De
16/06/2005 14:15:40
Keith Payne
Technical Marketing Solutions
Floride, États-Unis
 
 
À
16/06/2005 09:51:57
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
01023931
Message ID:
01024071
Vues:
22
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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform