博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mybatis配置and rownum< minus 查询第几行到第几行数据的sql原型和mybatis原型。
阅读量:4164 次
发布时间:2019-05-26

本文共 1384 字,大约阅读时间需要 4 分钟。

mybatis配置and rownum<  minus 查询第几行到第几行数据的sql原型和mybatis原型:

sql原型如下:

select

    
   t.pk_id as wq
  
    FROM t1t
    
    where dr=0
    
      and rownum<10  minus 
      
    
    
    select
    
    t.pk_id as 12
  
    FROM t1t
      where dr=0
    
      and rownum>2   
      
      order by JGqwMC desc

mybatis的mapper配置文件原型如下:

<select id="exportCurrentPage" resultMap="CorrectEndExcelMap"

parameterType="java.util.Map">
<if test="searchText != null">
<bind name="searchTextLike" value="'%' + _parameter.searchText + '%'" />
</if>
<if test="xm != null">
<bind name="xmLike" value="'%' + _parameter.xm + '%'" />
</if>
select
    
    t.pk_id as JGMC
  
    FROM t1  t
    
    <where>
<trim prefixOverrides="and">
 t.DR=0  
 <![CDATA[
and rownum<10  minus 
]]>
</trim>
    
     </where>
    
    select
    
    t.pk_id as JGMC
  
    FROM t1 t
    
    <where>
<trim prefixOverrides="and">
t.DR=0   and rownum>2 
</trim>
    
    </where>
      
      order by JGMC desc
</select>

注意:如果需要配置自定义的排序,需要如下设置,因为oracle的rownumber是不会变化的(此处的排序规则是:order by t.pk_id):

select * from(

select ROW_NUMBER() over(order by t.pk_id) as rowIndex , rownum,t.PK_ID
 FROM t1t
WHERE t.DR=0  and t.VSTATUS>=1
 ) t
 where   rowIndex<= 40 
 and  rowIndex>=20

或者利用minus写了更为复杂的写法(不推荐)

select * from(

select ROW_NUMBER() over(order by t.pk_id) as rowIndex , rownum,t.PK_ID

FROM t1 t 

WHERE t.DR=0 and   t.VSTATUS>=1
 ) t
 where   rowIndex<= 40 
minus
select * from(
select  ROW_NUMBER() over(order by t.pk_id) as rowIndex , rownum, t.PK_ID

FROM t1 t 

WHERE t.DR=0 and t.VSTATUS>=1 
 
) t
 where   rowIndex < 20 +1
 
 ;

此处的排序规则是:order by t.pk_id

转载地址:http://hsmxi.baihongyu.com/

你可能感兴趣的文章
SVG 滤镜学习之——SVG 滤镜
查看>>
mysql中用命令行复制表结构的方法
查看>>
hbase shell出现ERROR: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException
查看>>
让代码变得更优雅-Lombok
查看>>
解决Rhythmbox乱码
查看>>
豆瓣爱问共享资料插件发布啦
查看>>
Ubuntu10.10 CAJView安装 读取nh\kdh\caj文件 成功
查看>>
kermit的安装和配置
查看>>
vim 配置
查看>>
openocd zylin
查看>>
进程创建时文件系统处理
查看>>
内核线程创建
查看>>
linux中cat命令使用详解
查看>>
java中的异常机制
查看>>
java SE面向对象思维导图
查看>>
三维分析之视频投放
查看>>
SuperMap iDesktop之栅格值怎么查
查看>>
SuperMap iClient3D for WebGL教程-orientation
查看>>
SuperMap iClient3D for WebGL教程-description描述属性
查看>>
SuperMap iClient3D for WebGL教程-CallbackProperty
查看>>