oracle数据库内部分页

oracle数据库内部分页

//前端返回两个参数pageSize:每页数据量,pageNum:当前页码,
Map<String, Integer> betweenAndLast = PageUtil.getBetweenAndLast(pageSize, pageNum);
        String begin = betweenAndLast.get("begin").toString();
        String last = betweenAndLast.get("last").toString();
		List<AccountInfoVO> listInfo = accountInfoMapper.getKeyWordInfo(begin, last);//查询数据

查询数据的sql

  select *
  from (select rownum rn, T.*
          from (select t.taaccountid as accountCode,
                       t.individualorinstitution as accountType,
                       t.investorname as accountName,
                       t.appsheetserialno as applicationNumber,
                       t.transactioncfmdate as applicationDate,
                       t.f_custtype as clientType,
                       f.key_name as clientTypeName,
                       p.intercountyname || d.intercountyname as provincCity,
                       t.province as provinceNum,
                       p.intercountyname as provinceName,
                       t.city as cityNum,
                       d.intercountyname as cityName,
                       t.investorsbirthday as birthDate,
                       t.create_user as founderPeople,
                       t.create_time as founderTime,
                       t.modify_user as modifyPeople,
                       t.modify_time as modifyTime
                  from tc_pf_pb_ta_account t
                  left join tp_gl_county_code_map p
                    on t.province = p.intercode
                  left join tp_gl_county_code_map d
                    on t.city = d.intercode
                  left join tp_gl_exhib_datadict f
                    on f.key_id = t.f_custtype
                 where 1 = 1
                 order by case
                            when t.modify_time is not null then
                             t.modify_time
                            else
                             t.create_time
                          end desc) T) t
    where t.rn between #{begin} and #{last}--分页从第几行开始、结束

PageUtil.java

 /**
     * 根据前端传的第几页和每页显示的条数,计算分页的区间
     * @param limit 每页显示的条数
     * @param page  第几页
     * @return   begin:第几条开始   last:第几条结束
     **/
    public static Map<String, Integer> getBetweenAndLast(Integer limit, Integer page) {
        Map<String, Integer> map = new HashMap<>();

        //从第几条开始
        Integer begin = (limit * (page - 1)) + 1;
        //第几条结束
        Integer last = (limit * (page - 1)) + limit;
        map.put("begin", begin);
        map.put("last", last);
        return map;
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值