<?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; 2005 &#8211; Find Nth Highest Record from Database Table</title>
	<atom:link href="http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/</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: 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/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-47345</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>Wed, 25 Feb 2009 10:02:01 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-47345</guid>
		<description>[...] I have re-wrote the same article here with example of SQL Server 2005 Database AdventureWorks : SQL SERVER - 2005 - Find Nth Highest Record from Database ... [...]</description>
		<content:encoded><![CDATA[<p>[...] I have re-wrote the same article here with example of SQL Server 2005 Database AdventureWorks : SQL SERVER &#8211; 2005 &#8211; Find Nth Highest Record from Database &#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vidyullatha</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-44940</link>
		<dc:creator>vidyullatha</dc:creator>
		<pubDate>Fri, 19 Dec 2008 15:32:18 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-44940</guid>
		<description>hi ,
this is vidyullatha. i have a dought in sql how to get the nth highest salary from emp table.can i get using sql plz tell me the answer.</description>
		<content:encoded><![CDATA[<p>hi ,<br />
this is vidyullatha. i have a dought in sql how to get the nth highest salary from emp table.can i get using sql plz tell me the answer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Faith</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-44232</link>
		<dc:creator>Faith</dc:creator>
		<pubDate>Fri, 14 Nov 2008 22:39:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-44232</guid>
		<description>hi Vishwanath,

can you try this, where i&#039;m trying to find the third highest salary

select top 1 *
from (select top 3 *
          from emp_table
          order by  salary desc)
order by salary</description>
		<content:encoded><![CDATA[<p>hi Vishwanath,</p>
<p>can you try this, where i&#8217;m trying to find the third highest salary</p>
<p>select top 1 *<br />
from (select top 3 *<br />
          from emp_table<br />
          order by  salary desc)<br />
order by salary</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwanath</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-43408</link>
		<dc:creator>Vishwanath</dc:creator>
		<pubDate>Tue, 30 Sep 2008 15:58:56 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-43408</guid>
		<description>Hi nagesh,

Thank you for trying this. Can u pls help me out if their is any other query, as the result is not as expected.

This is not what i need.

Suppose i have a table with following data

EmpNo     Empname    sal

1             X                   100

2             y                    300

3             a                    50

4             b                   200

5             c                    500

6             d                    250



Here i want 3rd record i.e 3    a    50, using the sal column.

If i use ur query i will get  4    b     200  or if the order is changed u may get  6    d     250.
In which the result was not as i expected.
I just want the nth record it may or may not have duplicates</description>
		<content:encoded><![CDATA[<p>Hi nagesh,</p>
<p>Thank you for trying this. Can u pls help me out if their is any other query, as the result is not as expected.</p>
<p>This is not what i need.</p>
<p>Suppose i have a table with following data</p>
<p>EmpNo     Empname    sal</p>
<p>1             X                   100</p>
<p>2             y                    300</p>
<p>3             a                    50</p>
<p>4             b                   200</p>
<p>5             c                    500</p>
<p>6             d                    250</p>
<p>Here i want 3rd record i.e 3    a    50, using the sal column.</p>
<p>If i use ur query i will get  4    b     200  or if the order is changed u may get  6    d     250.<br />
In which the result was not as i expected.<br />
I just want the nth record it may or may not have duplicates</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nagesh</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-43223</link>
		<dc:creator>Nagesh</dc:creator>
		<pubDate>Wed, 24 Sep 2008 20:16:22 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-43223</guid>
		<description>Hi alll,

use this query for any record you want to find in the table. 


SELECT TOP A salary FROM (SELECT TOP (n) salary FROM employee ORDER BY salary  DESC)
AS E ORDER BY salary   ASC

top(n) give the total no of records

a desire top value

another way

select t.* from (select row_number() over(order by salary) as row_id, salary from sal)
t where t.row_id = 24

give the which nth record you want</description>
		<content:encoded><![CDATA[<p>Hi alll,</p>
<p>use this query for any record you want to find in the table. </p>
<p>SELECT TOP A salary FROM (SELECT TOP (n) salary FROM employee ORDER BY salary  DESC)<br />
AS E ORDER BY salary   ASC</p>
<p>top(n) give the total no of records</p>
<p>a desire top value</p>
<p>another way</p>
<p>select t.* from (select row_number() over(order by salary) as row_id, salary from sal)<br />
t where t.row_id = 24</p>
<p>give the which nth record you want</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwanath</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-42532</link>
		<dc:creator>Vishwanath</dc:creator>
		<pubDate>Mon, 08 Sep 2008 09:17:38 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-42532</guid>
		<description>Hi all,
i need to write a Query to find the nth record from a table. Please can any help me out?</description>
		<content:encoded><![CDATA[<p>Hi all,<br />
i need to write a Query to find the nth record from a table. Please can any help me out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vishwanath</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-42524</link>
		<dc:creator>Vishwanath</dc:creator>
		<pubDate>Mon, 08 Sep 2008 05:59:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-42524</guid>
		<description>How to get nth record(its not highest or lowest)  from a table. I am working on SQL SERVER 2005.</description>
		<content:encoded><![CDATA[<p>How to get nth record(its not highest or lowest)  from a table. I am working on SQL SERVER 2005.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Madhivanan</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-34353</link>
		<dc:creator>Madhivanan</dc:creator>
		<pubDate>Sat, 15 Mar 2008 09:32:10 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-34353</guid>
		<description>Many methods
http://sqlblogcasts.com/blog/madhivanan/archive/2007/08/27/find-nth-maximum-value.aspx</description>
		<content:encoded><![CDATA[<p>Many methods<br />
<a href="http://sqlblogcasts.com/blog/madhivanan/archive/2007/08/27/find-nth-maximum-value.aspx" rel="nofollow">http://sqlblogcasts.com/blog/madhivanan/archive/2007/08/27/find-nth-maximum-value.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: smita</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-34286</link>
		<dc:creator>smita</dc:creator>
		<pubDate>Wed, 12 Mar 2008 11:23:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-34286</guid>
		<description>Hi! Pinal,

What is Embedded SQL Query?</description>
		<content:encoded><![CDATA[<p>Hi! Pinal,</p>
<p>What is Embedded SQL Query?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - 2005 - Find Nth Highest Record from Database Table - Using Ranking Function ROW_NUMBER Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-34267</link>
		<dc:creator>SQL SERVER - 2005 - Find Nth Highest Record from Database Table - Using Ranking Function ROW_NUMBER Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Wed, 12 Mar 2008 01:31:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-34267</guid>
		<description>[...] 12, 2008 by pinaldave     I have previously written SQL SERVER - 2005 - Find Nth Highest Record from Database Table where I have shown query to find 4th highest record from database table. Everytime when I write [...]</description>
		<content:encoded><![CDATA[<p>[...] 12, 2008 by pinaldave     I have previously written SQL SERVER &#8211; 2005 &#8211; Find Nth Highest Record from Database Table where I have shown query to find 4th highest record from database table. Everytime when I write [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nicholas Paldino [.NET/C# MVP]</title>
		<link>http://blog.sqlauthority.com/2008/03/08/sql-server-2005-find-nth-highest-record-from-database-table/#comment-34262</link>
		<dc:creator>Nicholas Paldino [.NET/C# MVP]</dc:creator>
		<pubDate>Tue, 11 Mar 2008 18:27:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=530#comment-34262</guid>
		<description>If you are using SQL Server 2005, you are better off using the ranking function ROW_NUMBER, and then querying for the appropriate value:

select
	t.*
from
	(
		select
			e1.*,
			row_number() over (order by e1.Rate desc) as _Rank
		from
			HumanResources.EmployeePayHistory as e1
	) as t
where
	t._Rank = 3

Replace 3 with whatever rank you want (this will give you the record with the third highest rate).</description>
		<content:encoded><![CDATA[<p>If you are using SQL Server 2005, you are better off using the ranking function ROW_NUMBER, and then querying for the appropriate value:</p>
<p>select<br />
	t.*<br />
from<br />
	(<br />
		select<br />
			e1.*,<br />
			row_number() over (order by e1.Rate desc) as _Rank<br />
		from<br />
			HumanResources.EmployeePayHistory as e1<br />
	) as t<br />
where<br />
	t._Rank = 3</p>
<p>Replace 3 with whatever rank you want (this will give you the record with the third highest rate).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
