﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Teradata Forums / Analytical Applications / Teradata   / Getting one entry per RANK / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>Teradata Forums</description><link>http://www.teradata.com/teradataforum/</link><webMaster>info@teradata.com</webMaster><lastBuildDate>Sat, 06 Sep 2008 01:32:21 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Getting one entry per RANK</title><link>http://www.teradata.com/teradataforum/Topic4937-5-1.aspx</link><description>Carole,I know this is an old post, but for those looking at this, try doing something like this. select id_field, date_field, id2_fieldfrom table1where ... qualify rank() over (partition by id_field order by id_field, date_field desc, id2_field desc) = 1This will get the id_field for the max (rank = 1) date_field and exclude everything else where the rank isn't = 1 and the id2_field is a tie-breaker. If you don't have an id2_field, then you probably won't need a tie-breaker and you can simply exclude it from your query. Enjoy! tau</description><pubDate>Wed, 09 Apr 2008 15:56:37 GMT</pubDate><dc:creator>tajulrich</dc:creator></item><item><title>RE: Getting one entry per RANK</title><link>http://www.teradata.com/teradataforum/Topic4937-5-1.aspx</link><description>Hi Carole,&lt;br&gt;just add more columns to the Order By to make it unique or use row_number instead of rank...&lt;br&gt;&lt;br&gt;Dieter</description><pubDate>Sat, 19 Aug 2006 13:26:26 GMT</pubDate><dc:creator>dnoeth</dc:creator></item><item><title>Getting one entry per RANK</title><link>http://www.teradata.com/teradataforum/Topic4937-5-1.aspx</link><description>I need to get the most recent records (based on date) for each ID.  I cannot do a group by since there are too many non-aggregate values that I do not want to consider when grouping.  I have tried:&lt;br&gt;rank() over partition by ID,modification date order by modification date (DESC) &lt;br&gt;&lt;br&gt;However, when the dates are the same for more than one record for a specific ID I get the same rank.  I only need to pull one record per id and date when rank =1.&lt;br&gt;&lt;br&gt;Thanks&lt;br&gt;&lt;br&gt;Carole</description><pubDate>Fri, 18 Aug 2006 11:44:10 GMT</pubDate><dc:creator>carole</dc:creator></item></channel></rss>