0
1

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 3 years have passed since last update.

途中からのレコードデータを抽出するSQL

Posted at

#途中からのレコードデータを抽出するSQL
ORACLE SQLで、XXX行からYYY行までのレコードを抽出したかったので、そのためのSQLを備忘を含め以下に記載しました。

SELECT *
FROM
  (
    SELECT
      ROWNUM AS NUM     --疑似列
      ,B.*
    FROM
      (
        SELECT *
        FROM TABLE A
        ORDER BY
          AGE           --年齢
          ,GENDER       --性別
      ) B
  ) C
WHERE
  NUM BETWEEN 11 AND 20 --11行~20行のレコードを抽出

別のSQLならLIMIT OFFSET を使用すれば簡単に途中からのレコードを抽出できるのですが、ORACLEだと私の知る限りではこの方法しかないと思います、少々煩わしいですけど。

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?