用于oracle的一种sql分页方法

SELECT *
  FROM (SELECT a.*, ROWNUM row_num
          FROM (SELECT   t1.ajbh, t1.lrajbh, t2.nsrsbh, t2.nsrmc, t4.swjg_mc,
                         t5.jczt_mc,
                         CASE
                            WHEN t1.zgajwcrq IS NOT NULL
                               THEN   TRUNC (SYSDATE)
                                    - TRUNC (t1.zgajwcrq)
                         END AS yqts, ROWNUM row_num1
                    FROM ctais2wg.t03_ctais_ajxx t1,
                         ctais2wg.dj_nsrxx t2,
                         ctais2wg.jc_ajxx t3,
                         ctais2wg.dm_swjg t4,
                         ctais2wg.dm_jczt t5
                   WHERE t1.lrajbh = t3.ajbh
                     AND t2.nsrdzdah = t3.nsrdzdah
                     AND t4.swjg_dm = t3.ajsljg_j_dm
                     AND t5.jczt_dm = t3.jczt_dm
                ORDER BY yqts DESC) a) b
 WHERE b.row_num BETWEEN 1 AND 3

也就是说,把你的查询代码代替以下代码的{#}就可以了
SELECT *
  FROM (SELECT a.*, ROWNUM row_num FROM (
            {#}
        ) a) b
 WHERE b.row_num BETWEEN 1 AND 3

其中 BETWEEN 1 AND 3 是指页中的起始index和结束index

你可能感兴趣的:(oracle,sql,J#)