mysql-xml常用

    <select id="statisticByChat" resultType="com.wshoto.qrcode.service.common.bo.groupchat.GroupChatDayStatisticsData">
        SELECT
        gcs.chat_id,
        SUM ( gcs.entry_qty ) entry_qty,
        SUM ( gcs.withdraw_qty ) withdraw_qty,
        SUM ( gcs.increased_qty ) increased_qty
        FROM
        qr_group_chat_qrcode_day_statistics gcs
        WHERE
        1 = 1
        AND gcs.group_chat_qrcode_id = #{qrcodeId}
        AND gcs.tenant_id = #{tenantId}
        <if test="chatIdList !=null and chatIdList.size>0">
            AND chat_id in
            <foreach collection="chatIdList" separator="," item="item" open="(" close=")">
                #{item}
            </foreach>
        </if>
        GROUP BY
        gcs.chat_id
        ORDER BY
        <choose>
            <when test="orderBy == 2">
                entry_qty
            </when>
            <when test="orderBy  == 3">
                withdraw_qty
            </when>
            <when test="orderBy  == 4">
                increased_qty
            </when>
            <otherwise>
                chat_id
            </otherwise>
        </choose>
        <choose>
            <when test="direction == 'DESC'">
                DESC
            </when>
            <otherwise>
                ASC
            </otherwise>
        </choose>
    </select>

你可能感兴趣的:(mysql,xml,数据库)