We all know if we have to find range of data then we use sub queries but sql2005 provide row_number to find range of data
for ex.
if we have to select data from 21 row to 30 the n
SELECT * FROM
(
SELECT Row_Number() OVER (ORDER BY last_name, first_name) as rowid,
user_id,
last_name,
first_name
FROM user
) as a
where rowid >20 and rowid <31
same if i want 28 record the n
SELECT * FROM
(
SELECT Row_Number() OVER (ORDER BY last_name, first_name) as rowid,
user_id,
last_name,
first_name
FROM user
) as a
where rowid = 28
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment