<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Query to Retrieve the Nth Maximum Value</title>
	<atom:link href="http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: killer04</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-56198</link>
		<dc:creator>killer04</dc:creator>
		<pubDate>Sun, 27 Sep 2009 10:35:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-56198</guid>
		<description>Thanks a lot! This query works well.</description>
		<content:encoded><![CDATA[<p>Thanks a lot! This query works well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vivek</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-49594</link>
		<dc:creator>Vivek</dc:creator>
		<pubDate>Sat, 21 Mar 2009 02:18:14 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-49594</guid>
		<description>Hello Pinal Dave!!!
                             I am not able to understand why the following  query gave me the correct answer
&quot;SELECT *
FROM Employee E1
WHERE (N-1) = (
SELECT COUNT(DISTINCT(E2.Salary))
FROM Employee E2
WHERE E2.Salary &gt; E1.Salary)&quot;

Can you explain me in step by step manner how it returned correct answer?
I will be extremely thankful to you if you can do it for me.</description>
		<content:encoded><![CDATA[<p>Hello Pinal Dave!!!<br />
                             I am not able to understand why the following  query gave me the correct answer<br />
&#8220;SELECT *<br />
FROM Employee E1<br />
WHERE (N-1) = (<br />
SELECT COUNT(DISTINCT(E2.Salary))<br />
FROM Employee E2<br />
WHERE E2.Salary &gt; E1.Salary)&#8221;</p>
<p>Can you explain me in step by step manner how it returned correct answer?<br />
I will be extremely thankful to you if you can do it for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bharathiraja</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-44358</link>
		<dc:creator>Bharathiraja</dc:creator>
		<pubDate>Sat, 22 Nov 2008 15:23:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-44358</guid>
		<description>table_a   table_b

salary    salary
_____   _____
1000      2000
3000      4000

I want  a T-sql query  to get &quot;4000&quot; as answer</description>
		<content:encoded><![CDATA[<p>table_a   table_b</p>
<p>salary    salary<br />
_____   _____<br />
1000      2000<br />
3000      4000</p>
<p>I want  a T-sql query  to get &#8220;4000&#8243; as answer</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manohar</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-43270</link>
		<dc:creator>manohar</dc:creator>
		<pubDate>Fri, 26 Sep 2008 06:30:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-43270</guid>
		<description>Hi,

Can we find out the first inserted row from a table?

Regards
Manohar K Patidar Jamner (M. P. )</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Can we find out the first inserted row from a table?</p>
<p>Regards<br />
Manohar K Patidar Jamner (M. P. )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Satyabrata Paul</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-43107</link>
		<dc:creator>Satyabrata Paul</dc:creator>
		<pubDate>Mon, 22 Sep 2008 10:28:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-43107</guid>
		<description>Hi

following query will find out the nth max salary from employee table. just replace the number 5 with your number. Also it should check the duplicate value in salary field. I think Bala wants to know this.


SELECT max(salary) FROM ( SELECT DISTINCT TOP 5 salary FROM employee order by salary) a

Regards
Satyabrata Paul</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>following query will find out the nth max salary from employee table. just replace the number 5 with your number. Also it should check the duplicate value in salary field. I think Bala wants to know this.</p>
<p>SELECT max(salary) FROM ( SELECT DISTINCT TOP 5 salary FROM employee order by salary) a</p>
<p>Regards<br />
Satyabrata Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lawender</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-42495</link>
		<dc:creator>lawender</dc:creator>
		<pubDate>Sun, 07 Sep 2008 08:26:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-42495</guid>
		<description>Your query is correct if it came from student who has 5 minutes to solve this problem.

But if it in real world application,
Your query is very low performance.</description>
		<content:encoded><![CDATA[<p>Your query is correct if it came from student who has 5 minutes to solve this problem.</p>
<p>But if it in real world application,<br />
Your query is very low performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bala</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-41189</link>
		<dc:creator>Bala</dc:creator>
		<pubDate>Fri, 01 Aug 2008 17:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-41189</guid>
		<description>Hello sir,
       i have one dpubt........ 
How will we identify the duplicate key by refer the number?</description>
		<content:encoded><![CDATA[<p>Hello sir,<br />
       i have one dpubt&#8230;&#8230;..<br />
How will we identify the duplicate key by refer the number?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MilesPerSecond</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-41110</link>
		<dc:creator>MilesPerSecond</dc:creator>
		<pubDate>Thu, 31 Jul 2008 09:30:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-41110</guid>
		<description>Hi All,
I compared above said query and found this one performming like a Lamborghini Reventon as compared to the above proposed Ambassador, for table(id,name,salary) with 20K records:

DECLARE @myNth INT
SET @myNth=56
SELECT TOP 1 SALARY 
FROM(
                 SELECT TOP(@myNth) SALARY 
                 FROM MinMaxTable  
                 ORDER BY Salary DESC
          ) T 
ORDER BY Salary ASC 

So This one is the BEST !!!!</description>
		<content:encoded><![CDATA[<p>Hi All,<br />
I compared above said query and found this one performming like a Lamborghini Reventon as compared to the above proposed Ambassador, for table(id,name,salary) with 20K records:</p>
<p>DECLARE @myNth INT<br />
SET @myNth=56<br />
SELECT TOP 1 SALARY<br />
FROM(<br />
                 SELECT TOP(@myNth) SALARY<br />
                 FROM MinMaxTable<br />
                 ORDER BY Salary DESC<br />
          ) T<br />
ORDER BY Salary ASC </p>
<p>So This one is the BEST !!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Krishna</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-41029</link>
		<dc:creator>Krishna</dc:creator>
		<pubDate>Wed, 30 Jul 2008 05:50:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-41029</guid>
		<description>I want to find first 10 rows with max value from a table. 
and
 
how to get top 3 departments and bottom 3 departments
Can you suggest me what should be queries for above two questions?

Thanks 
krishna</description>
		<content:encoded><![CDATA[<p>I want to find first 10 rows with max value from a table.<br />
and</p>
<p>how to get top 3 departments and bottom 3 departments<br />
Can you suggest me what should be queries for above two questions?</p>
<p>Thanks<br />
krishna</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kapil Madan</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-35164</link>
		<dc:creator>Kapil Madan</dc:creator>
		<pubDate>Thu, 17 Apr 2008 12:18:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-35164</guid>
		<description>Hi executing the same query using Top keyword is much faster, when the number of records are comparatively too large. FYI (copied from the same site :) )

SELECT TOP 1 salary 
    FROM (
    SELECT DISTINCT TOP 6 salary 
        FROM employee
        ORDER BY salary DESC) a 
    ORDER BY salary</description>
		<content:encoded><![CDATA[<p>Hi executing the same query using Top keyword is much faster, when the number of records are comparatively too large. FYI (copied from the same site :) )</p>
<p>SELECT TOP 1 salary<br />
    FROM (<br />
    SELECT DISTINCT TOP 6 salary<br />
        FROM employee<br />
        ORDER BY salary DESC) a<br />
    ORDER BY salary</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Find Nth Highest Salary of Employee - Query to Retrieve the Nth Maximum value Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-34879</link>
		<dc:creator>SQL SERVER - Find Nth Highest Salary of Employee - Query to Retrieve the Nth Maximum value Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Sun, 06 Apr 2008 08:36:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-34879</guid>
		<description>[...] Please read my article here to find Nth Highest Salary of Employee table : SQL SERVER - Query to Retrieve the Nth Maximum value [...]</description>
		<content:encoded><![CDATA[<p>[...] Please read my article here to find Nth Highest Salary of Employee table : SQL SERVER &#8211; Query to Retrieve the Nth Maximum value [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2005 - Find Nth Highest Record from Database Table Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-34256</link>
		<dc:creator>SQL SERVER - 2005 - Find Nth Highest Record from Database Table Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:00:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-34256</guid>
		<description>[...] 8, 2008 by pinaldave    I have previously written SQL SERVER - Query to Retrieve the Nth Maximum value. I just received email that if I can write this using AdventureWorks database as it is default [...]</description>
		<content:encoded><![CDATA[<p>[...] 8, 2008 by pinaldave    I have previously written SQL SERVER &#8211; Query to Retrieve the Nth Maximum value. I just received email that if I can write this using AdventureWorks database as it is default [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srinath</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-34180</link>
		<dc:creator>srinath</dc:creator>
		<pubDate>Fri, 07 Mar 2008 13:46:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-34180</guid>
		<description>hi 

  i want a query .dynamicale i new row should Added and it should display in Gui  by using a Query.pleas provide me this query.

Regards
Srinath</description>
		<content:encoded><![CDATA[<p>hi </p>
<p>  i want a query .dynamicale i new row should Added and it should display in Gui  by using a Query.pleas provide me this query.</p>
<p>Regards<br />
Srinath</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sekar</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-34002</link>
		<dc:creator>sekar</dc:creator>
		<pubDate>Wed, 27 Feb 2008 01:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-34002</guid>
		<description>Hi,

Thanks for the perfect solution to find out the Nth record from sql server database.

One request:
how to get top 3 departments and bottom 3 departments

waiting for ur reply

with reagards
sekar</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for the perfect solution to find out the Nth record from sql server database.</p>
<p>One request:<br />
how to get top 3 departments and bottom 3 departments</p>
<p>waiting for ur reply</p>
<p>with reagards<br />
sekar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: uday</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-33778</link>
		<dc:creator>uday</dc:creator>
		<pubDate>Fri, 15 Feb 2008 12:41:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-33778</guid>
		<description>how to get top 3 departments and bottom 3 departments</description>
		<content:encoded><![CDATA[<p>how to get top 3 departments and bottom 3 departments</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manohari</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-33367</link>
		<dc:creator>manohari</dc:creator>
		<pubDate>Wed, 30 Jan 2008 12:49:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-33367</guid>
		<description>Tks for u r solution</description>
		<content:encoded><![CDATA[<p>Tks for u r solution</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjusha</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-33249</link>
		<dc:creator>Manjusha</dc:creator>
		<pubDate>Thu, 24 Jan 2008 09:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-33249</guid>
		<description>Hi,
Tanks for the perfect n easy solution.

Thanks n Regards,
Manjusha</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Tanks for the perfect n easy solution.</p>
<p>Thanks n Regards,<br />
Manjusha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinod Parihar</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-33002</link>
		<dc:creator>Vinod Parihar</dc:creator>
		<pubDate>Thu, 17 Jan 2008 07:09:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-33002</guid>
		<description>Dear Sir/Madam,

Thanks for the perfect solution to find out the Nth record from sql server database.</description>
		<content:encoded><![CDATA[<p>Dear Sir/Madam,</p>
<p>Thanks for the perfect solution to find out the Nth record from sql server database.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BalaMurugan.A</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-32221</link>
		<dc:creator>BalaMurugan.A</dc:creator>
		<pubDate>Fri, 11 Jan 2008 06:42:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-32221</guid>
		<description>Your examples are very useful in my job</description>
		<content:encoded><![CDATA[<p>Your examples are very useful in my job</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shaheen</title>
		<link>http://blog.sqlauthority.com/2007/04/27/sql-server-query-to-retrieve-the-nth-maximum-value/#comment-12898</link>
		<dc:creator>Shaheen</dc:creator>
		<pubDate>Mon, 17 Sep 2007 07:47:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/04/27/query-to-retrieve-the-nth-maximum-value/#comment-12898</guid>
		<description>Select Top 10 distinct Name,Vlaue from Table1 order by Value desc</description>
		<content:encoded><![CDATA[<p>Select Top 10 distinct Name,Vlaue from Table1 order by Value desc</p>
]]></content:encoded>
	</item>
</channel>
</rss>
