SQL Server Performance

to select from 5 to 10 rows from a table

Discussion in 'Getting Started' started by kumar_kisna, May 11, 2007.

  1. kumar_kisna New Member

    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
  2. Madhivanan Moderator

  3. chiragkhabaria New Member

  4. satya Moderator

    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.

Share This Page