分页查询

mybatis 写道
<parameterMap type="map" id="paramMap">
  <parameter property="chnName" javaType="java.lang.String" jdbcType="VARCHAR"/>
  <parameter property="startDate" javaType="java.util.Date" jdbcType="DATE"/>
  <parameter property="endDate" javaType="java.util.Date" jdbcType="DATE"/>
  <parameter property="pageNo" javaType="int" jdbcType="INTEGER"/>
  <parameter property="pageSize" javaType="int" jdbcType="INTEGER"/>
 </parameterMap>
<select id="queryHotelPriceByName" resultMap="hkHotelPrice" parameterMap="paramMap">
select * from (
select t.*,rownum rn from (
select CHN_NAME,CASE MAX(CITY_CODE) WHEN 'MAC' THEN '澳门' WHEN 'HKG' THEN '香港' END CITY_CODE,
NATIONAL_CODE_DESCR, MIN(SETTLE_AMT) SETTLE_AMT,MIN(LIST_PRICE) LIST_PRICE from PKG_CTSHKHOTELPRICE
WHERE CHN_NAME LIKE CONCAT(CONCAT('%', #{chnName}),'%')
<![CDATA[ AND START_DATE >= #{startDate} ]]>
<![CDATA[ AND START_DATE <= #{endDate} ]]>
GROUP BY CHN_NAME,NATIONAL_CODE_DESCR) t)
where <![CDATA[ rn > (#{pageNo}-1)* #{pageSize} ]]>
<![CDATA[and rn <= (#{pageNo})* #{pageSize}]]>
</select>

<select id="queryHotelPriceByNamePage" resultType="int" parameterMap="paramMap">
SELECT COUNT(*) FROM (
SELECT CHN_NAME,NATIONAL_CODE_DESCR, MIN(SETTLE_AMT) SETTLE_AMT,MIN(LIST_PRICE) LIST_PRICE
FROM PKG_CTSHKHOTELPRICE
WHERE CHN_NAME LIKE CONCAT(CONCAT('%', #{chnName}),'%')
<![CDATA[ AND START_DATE >= #{startDate} ]]>
<![CDATA[ AND START_DATE <= #{endDate} ]]>
GROUP BY CHN_NAME,NATIONAL_CODE_DESCR)
</select>

 

你可能感兴趣的:(分页查询)