Mybatis 聚合函数

来源:互联网 发布:江南七怪 知乎 编辑:程序博客网 时间:2024/06/15 05:41
    </select>
    <!-- 折线图 -->
    <select id="selectBroken" resultType="map">
        select sum(t.score_num) score_num,trunc(t.tim/10000) tim(聚合函数必须区别名!!)
        from tbl_score_log t where 1= 1
        <if test="beginDate != null and beginDate!= '' ">
            tim &gt;= #{beginDate}
          </if>
        <if test="endDate != null and endDate != '' ">
            and tim &lt;= #{endDate}
           </if>
        <if test="uid!=null and uid!='' ">
            and t.user_id =#{uid}
            </if>
        <if test="type !=null and type!= '' ">
            and t.score_type = #{type}
         </if>
        group by trunc(t.tim/10000)
    </select>
0 0
原创粉丝点击