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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Remove Duplicated based on one column

Author  Topic 

kev8279
Starting Member

6 Posts

Posted - 2014-07-18 : 02:59:13
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

737 Posts

Posted - 2014-07-18 : 03:15:31
apply a where condition max(yourdatecolumn) to your existing query

Javeed Ahmed
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-07-18 : 04:14:15
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
   

- Advertisement -