Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to find latest record/sales of a customer

Author  Topic 

vandana
Starting Member

29 Posts

Posted - 2013-01-16 : 04:56:28
Hi,

i have a table with 3 columns (cname,sales,date)
i want to know the latest sales of particular customer
can anyone suggest me the query to do this

Thanks in advance

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-01-16 : 05:56:39
SELECT TOP 1 WITH TIES *
FROM YourTable
WHERE cname = @CustomerName
ORDER BY date DESC

--
Chandu
Go to Top of Page

vandana
Starting Member

29 Posts

Posted - 2013-01-16 : 06:07:09
Thanks chandhu it worked !!!!
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-01-16 : 06:53:41
quote:
Originally posted by vandana

Thanks chandhu it worked !!!!


Welcome

--
Chandu
Go to Top of Page
   

- Advertisement -