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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Remove Duplicated based on one column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kev8279
Starting Member

United Kingdom
6 Posts

Posted - 07/18/2014 :  02:59:13  Show Profile  Reply with Quote
Hi,

I have a table that brings back 3 calls from a customer on the same date but different times. What I want is a query that will only bring back the customer once and I want that one record to be the latest time in the day. Any ideas?

ahmeds08
Aged Yak Warrior

India
649 Posts

Posted - 07/18/2014 :  03:15:31  Show Profile  Send ahmeds08 a Yahoo! Message  Reply with Quote
apply a where condition max(yourdatecolumn) to your existing query

Javeed Ahmed
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
30250 Posts

Posted - 07/18/2014 :  04:14:15  Show Profile  Visit SwePeso's Homepage  Reply with Quote
Use the ROW_NUMBER() function and partition by customer and order by date descending.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.08 seconds. Powered By: Snitz Forums 2000