<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.demo.mapper.BrandEvolveDao">
    <select id="selectByMulti" resultType="com.ruoyi.demo.entity.vo.BrandEvolveVo">
        SELECT
            brand_id,
            brand_name,
            SUM(count) total,
            DATE_FORMAT(stat_time, '%Y-%m') time
        FROM
            `bl_brand_evolve_statistics`
        <where>
            brand_id = #{brandId}
            <if test="addrCodes != null">
                <foreach collection="addrCodes" item="code" open="AND addr_code IN (" separator="," close=")">
                    #{code,jdbcType=VARCHAR}
                </foreach>
            </if>
            <if test="typeCodes != null">
                <foreach collection="typeCodes" item="code" open="AND type_code_by IN (" separator="," close=")">
                    #{code,jdbcType=VARCHAR}
                </foreach>
            </if>
        </where>
        GROUP BY
            brand_id,
            brand_name,
            time
        ORDER BY
            time;
    </select>
</mapper>
