Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning the most recent of several rows
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00605632
Message ID:
00605881
Vues:
9
Just add "TOP 1" after the word select!

BOb


>Hi all,
>
>I'm stumped here and I need somebody to "turn me in the right direction and push" (bg).
>
>Situation:
>I have a query which returns rows from a "status log" table for customers, which looks something like:
>
>
>SELECT LastName, FirstName, StatusCode, TimeCreated, CallID, AssociateID
>FROM Customers
>INNER JOIN CustStatus ON Customers.CallID = CustStatus.CallID
>ORDER BY 6, 1, 2, 4 DESC
>
>
>This returns all the status rows for each open customer, with the most recent status row as the first row for each customer. This works perfectly.
>
>PROBLEM:
>What I'm looking to do is modify this query so that *ONLY THE MOST RECENT STATUS ROW* is returned for each customer.
>
>Any ideas, gang? There's *got* to be an easy way to do this that I'm just not thinking about...
>
>TIA,
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform