﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Discuss Content Posted by M. Choirul Amri / Article Discussions / Article Discussions by Author  / SQL 2005 for the SQL2K Developer Part 2 / 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>Tue, 18 Jun 2013 22:02:58 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>Absolutely.  The example given for the Top 10 was too simple to benefit (unless of course you're trying to port something to/from a system that does not support the TOP keyword).  If you want to sample values from every 10th item, or need to grab the #s 11-20; or #s 31-40 (or combinations, etc.), ROW_NUMBER is much easier to use (and often considerably faster) than most alternatives.  The alternatives often include a lot of complex self-joins to "number" the rows to achieve this same effect.</description><pubDate>Mon, 14 May 2007 08:44:00 GMT</pubDate><dc:creator>Mike C</dc:creator></item><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>Are you saying that in the case of "discount the price for the top 10 most expensive products" that using TOP would indeed be a better choice, but for more complicated requirements ROW_NUMBER provides a valuable alternative to complicated queries?</description><pubDate>Mon, 14 May 2007 07:18:00 GMT</pubDate><dc:creator>rlively-343684</dc:creator></item><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>&lt;P&gt;What's more difficult is something like this:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;UPDATE ProductsSET UnitPrice = 0.9 * UnitPriceWHERE ProductID IN(SELECT ProductID FROM(SELECT ROW_NUMBER() OVER (ORDER BY UnitPrice DESC) AS Number, ProductID FROM Products) AS BWHERE Number % 10 = 0)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Or&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;UPDATE ProductsSET UnitPrice = 0.9 * UnitPriceWHERE ProductID IN(SELECT ProductID FROM(SELECT ROW_NUMBER() OVER (ORDER BY UnitPrice DESC) AS Number, ProductID FROM Products) AS BWHERE (Number &amp;gt;= 10 AND Number &amp;lt; 20)OR (Number &amp;gt;= 50 AND Number &amp;lt; 60))&lt;/FONT&gt;&lt;/P&gt;</description><pubDate>Fri, 11 May 2007 18:51:00 GMT</pubDate><dc:creator>Mike C</dc:creator></item><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>Couldn't this same query:UPDATE ProductsSET UnitPrice = 0.9 * UnitPriceWHERE ProductID IN(  SELECT ProductID FROM(  SELECT ROW_NUMBER() OVER (ORDER BY UnitPrice DESC) AS Number, ProductID FROM Products) AS B  WHERE Number &lt; = 10)Be written in SQL2k (or SQL2005 for that matter) using TOP instead of ROW_NUMBER?  This query even looks simpler and easier to understand:UPDATE ProductsSET UnitPrice = 0.9 * UnitPriceWHERE ProductID IN(  SELECT TOP 10 ProductID FROM Products  ORDER BY UnitPrice DESC)</description><pubDate>Fri, 11 May 2007 06:53:00 GMT</pubDate><dc:creator>rlively-343684</dc:creator></item><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>&lt;P&gt;You can get the old sample databases no longer included in 2005 here:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=06616212-0356-46A0-8DA2-EEBC53A68034&amp;amp;displaylang=en#Instructions"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyId=06616212-0356-46A0-8DA2-EEBC53A68034&amp;amp;displaylang=en#Instructions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;hth&lt;/P&gt;</description><pubDate>Thu, 11 May 2006 07:13:00 GMT</pubDate><dc:creator>omhoge</dc:creator></item><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>Hi Mike Cthanks for remind for such cool sequential ordering &lt;img src='images/emotions/smile.gif' height='20' width='20' border='0' title='Smile' align='absmiddle'&gt;</description><pubDate>Thu, 11 May 2006 03:23:00 GMT</pubDate><dc:creator>Muhammad Choirul Amri</dc:creator></item><item><title>RE: SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>&lt;P&gt;Don't forget &lt;FONT face="Courier New"&gt;RANK(), DENSE_RANK()&lt;FONT face=Arial&gt; and&lt;/FONT&gt; NTILE()&lt;/FONT&gt;.  See &lt;A href="http://www.sqlservercentral.com/columnists/mcoles/sequentialordering.asp"&gt;http://www.sqlservercentral.com/columnists/mcoles/sequentialordering.asp&lt;/A&gt; for more info.  Also discusses other reasons &lt;FONT face="Courier New"&gt;IDENTITY&lt;/FONT&gt; column and other options are not optimal solutions.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description><pubDate>Wed, 10 May 2006 21:16:00 GMT</pubDate><dc:creator>Mike C</dc:creator></item><item><title>SQL 2005 for the SQL2K Developer Part 2</title><link>http://www.sqlservercentral.com/Forums/Topic273439-288-1.aspx</link><description>Comments posted to this topic are about the content posted at &lt;A HREF="http://www.sqlservercentral.com/columnists/mcAmri/sql2005forthesql2kdeveloperpart2.asp"&gt;http://www.sqlservercentral.com/columnists/mcAmri/sql2005forthesql2kdeveloperpart2.asp&lt;/A&gt;</description><pubDate>Fri, 14 Apr 2006 18:15:00 GMT</pubDate><dc:creator>Muhammad Choirul Amri</dc:creator></item></channel></rss>