﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / Exclude duplicates, keep the value with the latest date / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Mon, 20 May 2013 20:30:26 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>[quote][b]5280_Lifestyle (2/26/2013)[/b][hr]Sean's solution worked. Thank you very much![/quote]You are quite welcome. Glad that worked for you.</description><pubDate>Wed, 27 Feb 2013 07:56:18 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>Sean's solution worked. Thank you very much!</description><pubDate>Tue, 26 Feb 2013 08:05:14 GMT</pubDate><dc:creator>5280_Lifestyle</dc:creator></item><item><title>RE: Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>[quote][b]BriPan (2/26/2013)[/b][hr]but If performance is in concern then go for[code="sql"]select CandidateID, max(YourDateColumn)from YourTablegroup by CandidateID [/code][/quote]Sean's solution is almost certainly quicker than Kingston's ROW_NUMBER method; however, Kingston's solution is a viable alternative which introduces the method to those who may not already be familiar with it - and of course, it demonstrates how to identify the target rows without necessarily filtering out those which are not targeted.</description><pubDate>Tue, 26 Feb 2013 03:48:47 GMT</pubDate><dc:creator>ChrisM@Work</dc:creator></item><item><title>RE: Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>but If performance is in concern then go for[code="sql"]select CandidateID, max(YourDateColumn)from YourTablegroup by CandidateID [/code]</description><pubDate>Tue, 26 Feb 2013 03:39:54 GMT</pubDate><dc:creator>BriPan</dc:creator></item><item><title>RE: Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>You can also use ROW_NUMBER()[code="sql"]SELECT	*FROM	(		SELECT	ROW_NUMBER() OVER ( PARTITION BY CandidateID ORDER BY YourDateColumn DESC ) AS RN, *		FROM	YourTable	) AS YTWHERE	YT.RN = 1[/code]</description><pubDate>Tue, 26 Feb 2013 00:50:44 GMT</pubDate><dc:creator>Kingston Dhasian</dc:creator></item><item><title>RE: Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>[quote][b]5280_Lifestyle (2/25/2013)[/b][hr]I'm trying to create a query with multiple columns. The CandidateID column includes values that appear more than once. I need my query to return the latest CandidateID value and to exclude the older CandidateID values of the same ID number.[/quote]Like this?select CandidateID, max(YourDateColumn)from YourTablegroup by CandidateID</description><pubDate>Mon, 25 Feb 2013 18:00:05 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>Exclude duplicates, keep the value with the latest date</title><link>http://www.sqlservercentral.com/Forums/Topic1423816-1292-1.aspx</link><description>I'm trying to create a query with multiple columns. The CandidateID column includes values that appear more than once. I need my query to return the latest CandidateID value and to exclude the older CandidateID values of the same ID number.Sample values:[code="plain"]200843	2012-02-14 07:49:00200843	2012-02-15 06:56:00231022	2012-02-14 07:49:00233525	2012-01-30 21:15:00276699	2012-01-30 21:14:00291019	2012-01-30 21:15:00298805	2012-01-30 21:15:00298805	2012-02-15 06:56:00298805	2012-02-21 09:39:00306011	2012-02-14 07:49:00306011	2012-02-15 06:56:00306011	2012-02-21 09:55:00313538	2012-01-30 21:15:00316135	2012-01-30 21:14:00[/code]I need the query to return the following...[code="plain"]200843	2012-02-15 06:56:00231022	2012-02-14 07:49:00233525	2012-01-30 21:15:00276699	2012-01-30 21:14:00291019	2012-01-30 21:15:00298805	2012-02-21 09:39:00306011	2012-02-21 09:55:00313538	2012-01-30 21:15:00316135	2012-01-30 21:14:00[/code]</description><pubDate>Mon, 25 Feb 2013 16:31:32 GMT</pubDate><dc:creator>5280_Lifestyle</dc:creator></item></channel></rss>