Select top records without using TOP keyword

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deveshakgec
    New Member
    • Nov 2013
    • 5

    Select top records without using TOP keyword

    Here we are using CTE

    Code:
    WITH CTE AS (
       SELECT Col1, rowno = row_number() OVER(ORDER BY Col2)
       FROM Table
       
    )
    SELECT *
    FROM   CTE
    WHERE  rowno BETWEEN 1 AND 5
    Last edited by Rabbit; Nov 13 '13, 04:39 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data.

    What is your question? You seem to have answered yourself.

    Comment

    Working...