24
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SQLServerで、MySQLのLIMIT句、OFFSET句みたいなもの

Last updated at Posted at 2014-06-11

SQLServer 2008以前では副問い合わせにしてROW_NUMBER()を使って絞り込みます。

SELECT * FROM (
  SELECT
	ROW_NUMBER() OVER(ORDER BY ba.LASTUPDATE DESC) as RN
	, *
  FROM T_TEST as ba
) as t
where t.RN BETWEEN 51 AND 100

SQLServer 2012ではOFFSET-FETCH句が使えるようになりました。

SELECT *
FROM T_TEST
ORDER BY LASTUPDATE DESC
OFFSET 50 ROWS
FETCH NEXT 50 ROWS ONLY
24
24
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
24

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?