Just Code‎ > ‎

T SQL - How to get row numbers from select query

posted Aug 27, 2009, 1:23 AM by Peter Henell   [ updated Sep 29, 2009, 2:19 AM ]
select *, ROW_NUMBER() OVER (Order by id) as rownum from customers

eller

WITH tableAlias (Item, RN)
AS
( SELECT
FirstName,
    RN = ROW_NUMBER() OVER (ORDER BY CustomerID DESC)

FROM dbo.Customer
)
select * from
tableAlias where RN = 3
Comments