sql server query | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

sql server query

how can i display Nth row from a table
for example I have 10 rows in my table. I want to display 6th row of my table.
can any body help me

http://www.sql-server-performance.com/faq/sqlviewfaq.aspx?topicid=1&faqid=124 Satya SKJ
Microsoft SQL Server MVP
Writer, Contributing Editor & Moderator
http://www.SQL-Server-Performance.Com
This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
Will need to update that FAQ. In SQL Server 2005 you could also use ROW_NUMBER() like
SELECT *
FROM(
SELECT ROW_NUMBER() OVER(ORDER BY OrderID) AS ‘RowNumber’
, OrderID
FROM Northwind.db:confused:rders
) t
WHERE RowNumber = 5

Frank Kalis
Moderator
Microsoft SQL Server MVP
Webmaster:http://www.insidesql.de
quote:Originally posted by js.reddy how can i display Nth row from a table
for example I have 10 rows in my table. I want to display 6th row of my table.
can any body help me
Do google search on "Find Nth Maximum value" for other methods Madhivanan Failing to plan is Planning to fail
Thanks, I will update it then.[<img src=’/community/emoticons/emotion-1.gif’ alt=’:)‘ />]<br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by FrankKalis</i><br /><br />Will need to update that FAQ. In SQL Server 2005 you could also use ROW_NUMBER() like<br /><pre id="code"><font face="courier" size="2" id="code"><br />SELECT * <br /> FROM(<br /> SELECT ROW_NUMBER() OVER(ORDER BY OrderID) AS ‘RowNumber'<br /> , OrderID<br /> FROM Northwind.db:confused:rders<br /> ) t<br /> WHERE RowNumber = 5<br /></font id="code"></pre id="code"><br /><br />–<br />Frank Kalis<br />Moderator<br />Microsoft SQL Server MVP<br />Webmaster:<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a><br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br /><b>Satya SKJ</b><br />Microsoft SQL Server MVP<br />Writer, Contributing Editor & Moderator<br /<a target="_blank" href=http://www.SQL-Server-Performance.Com>http://www.SQL-Server-Performance.Com</a><br /><center><font color="teal"><font size="1">This posting is provided AS IS with no rights for the sake of <i>knowledge sharing. <hr noshade size="1">Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.</i></font id="size1"></font id="teal"></center>
]]>