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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to find latest record/sales of a customer
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vandana
Starting Member

29 Posts

Posted - 01/16/2013 :  04:56:28  Show Profile  Reply with Quote
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

Edited by - vandana on 01/16/2013 05:18:34

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 01/16/2013 :  05:56:39  Show Profile  Reply with Quote
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 - 01/16/2013 :  06:07:09  Show Profile  Reply with Quote
Thanks chandhu it worked !!!!
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 01/16/2013 :  06:53:41  Show Profile  Reply with Quote
quote:
Originally posted by vandana

Thanks chandhu it worked !!!!


Welcome

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000