Wednesday, June 20, 2012

SQL - Select Query Limit

"LIMIT" in SQL Server

 

Syntax:

SELECT * FROM
( SELECT *, ROW_NUMBER() OVER (ORDER BY tablename) as row FROM tablename) a WHERE row > 1 and row <= 3


Example:


SELECT * FROM
( SELECT *, ROW_NUMBER() OVER (ORDER BY LogDateTime) as row FROM TblUserActiveLog ) a WHERE row > 1 and row <= 3

No comments:

Post a Comment