sql小计,查询大于一条,日期转换比较,forEach循环,case when

一:查询大于一条的数据
select
       xxx,xxx,count(*)
from
        T_ACCT_INFO a
        group by xxx,xxx
        having count(*)>1
二:like语句
<if test= "X.xxx !=null and X.xxx != ''">
      AND x_x_x LIKE CONCAT(CONCAT('%',#{X.xxx }),'%')
</if>
三:日期转换比较
<if test="X.xxx != null and X.xxx != ''">
   AND <![CDATA[ TO_CHAR(x_x_x,'yyyy-MM-dd') >= #{X.xxx}]]>
</if>
四:forEach循环
 1)循环数据
<if test="X.xxx == "0" or X.xxx == null">
   AND x_x_x IN
    <foreach collection="X.xxx" index="index" item="item" open="(" separator="," close=")">
       #{item}
  </foreach>
</if>
2)循环对象  链接对象为OR
<if test="X.xxx!=null and X.xxx.size()>0">
  AND
    <foreach collection="X.xxx" index="index" item="item" open="(" separator=" OR " close=")">
           (
            x_x_x  = #{item.xx}
            and
            x_x_x  = #{item.xx}
            and
            x_x_x  = #{item.xx}
            )
  </foreach>
 </if>
五:case when
case when x_x_x   = #{X.xxx} then 1 else null end

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值