Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning the most recent of several rows
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00605632
Message ID:
00605881
Views:
11
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,
Previous
Reply
Map
View

Click here to load this message in the networking platform