to select from 5 to 10 rows from a table | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

to select from 5 to 10 rows from a table

hi all
there is a table containing 30 rows in the predefined manner….and i need to select rows from 5 to 10 which are currently in the table….help me in writing the query for the same

You need pagination http://www.aspfaq.com/show.asp?id=2120 Madhivanan Failing to plan is Planning to fail
Well.. here is the excellent link for paging i had come across so far.. http://dotnetjunkies.com/Tutorial/EA868776-D71E-448A-BC23-B64B871F967F.dcik IF you want in the SQL its self.. do post your table structure and which version of SQL SERVER you are using.. Chirag http://chirikworld.blogspot.com/
SELECT * FROM (
SELECT TOP x * FROM (
SELECT TOP y fields
FROM table
WHERE conditions
ORDER BY table.field ASC) as foo
ORDER by field DESC) as bar
ORDER by field ASC
You replace x & y various with desirable numbers. 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.
]]>