I'm trying to show only a selected number of rows from the database(say from 20 to 45) I'm trying to use limit but it is not working
Select *
from UsersTable
limit 20,45
It is wrong since SQL Server doesn't allow this feature.
The answer that I found is
SELECT *
FROM
(SELECT
*, ROW_NUMBER() OVER (ORDER BY name) AS row
FROM
sys.databases) a
WHERE
row > 20 and row <= 45
Can someone simplify this? I am not able to follow the above query, what is (ORDER BY name)
in it
Say my database has the columns Id, UserName, Email
and values in my Id
column will be like 1, 2, 4, 8, 11, 17
-> not continuous values