目录
查找最大数
select max(t.sort_order) from content t
查找总数和数量
<select id="##" parameterType="map" resultType="map">
SELECT
(SELECT SUM(AMOUNT) FROM PAY T WHERE T.CARD_ID IN (SELECT B.ID FROM CARD B WHERE B.ID = #{id} ) ) amount,
(SELECT COUNT(1) FROM PAY T WHERE T.CARD_ID IN (SELECT B.ID FROM CARD B WHERE B.ID = #{id} ) ) payTimes
FROM DUAL
</select>
IF语句
<select id="##" parameterType="map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM ** T
LEFT JOIN USER M
ON T.ID = M.ID
WHERE 1 = 1
<if test="type != null and type != ''">
AND T.TYPE = #{type ,jdbcType=VARCHAR}
</if>
</select>
根据指定年月查询
<select id="##" resultType="java.lang.Double" parameterType="map" >
SELECT COUNT(*) amount FROM **C
LEFT JOIN USER M ON C.ID = M.ID WHERE 1 = 1
<if test="year!= null and year > 0 and (month == null or month == 0)">
AND TO_NUMBER(TO_CHAR(C.CREATION_TIME 'YYYY')) = #{year ,jdbcType=DECIMAL}
</if>
<if test="year!= null and year > 0 and month != null and month > 0">
AND TO_NUMBER(TO_CHAR(C.CREATION_TIME, 'YYYY')) = #{year ,jdbcType=DECIMAL}
AND TO_NUMBER(TO_CHAR(C.CREATION_TIME, 'MM')) = #{month ,jdbcType=DECIMAL}
</if>
</select>