「SQLServer」top、offsetで検索結果件数を指定する
1.1件目からn件取得
書式
top 件数
使用例
select
top 3 uid
, username
, address
from
user_tbl
select
top 3 uid
, username
, address
from
user_tbl
select top 3 uid , username , address from user_tbl
2.指定件目からn件取得
書式
offset 件目 rows fetch next 件数 rows only
使用例
select
*
from
user_tbl
order by
Id offset 4 rows fetch next 3 rows only
select
*
from
user_tbl
order by
Id offset 4 rows fetch next 3 rows only
select * from user_tbl order by Id offset 4 rows fetch next 3 rows only