<?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.casic.missiles.mapper.customer.CustomerWorkbenchMapper">

    <select id="sampleIncreaseTrend" resultType="Map">
        SELECT  increaseTime,count(increaseTimes) AS  "count"
        FROM (
                SELECT DATE_FORMAT(create_time, '%Y%m' ) AS  increaseTime,COUNT(*) AS increaseTimes,create_time
                FROM  customer_sample_info
                WHERE TIMESTAMPDIFF(MONTH,now(),create_time)   <![CDATA[ <= ]]> 12
                AND is_del=0
                GROUP BY create_time
        ) sampleInfo
        GROUP BY increaseTime
    </select>

    <select id="querySampleExpireTrend" resultType="Map">
        SELECT
        expireTime,
        count( expireTimes ) AS "count"
        FROM
        (
            SELECT DATE_FORMAT(update_time, '%Y%m' ) AS "expireTime",
            COUNT(*) AS expireTimes
            FROM
            customer_sample_info
            WHERE
            TIMESTAMPDIFF( MONTH, now(), update_time )   <![CDATA[ <= ]]>  12 AND is_del = 0
            AND sysdate()   <![CDATA[ > ]]>  DATE_FORMAT(valid_deadline,'%Y-%m-%d')
            GROUP BY expireTime
        ) sampleInfo
        GROUP BY expireTime
    </select>

    <select id="customerIncreaseTrend" resultType="Map">
        SELECT  increaseTime,count(increaseTimes) AS  "count"
        FROM (
            SELECT DATE_FORMAT(create_time, '%Y%m' ) AS  increaseTime,COUNT(*) AS increaseTimes,create_time
                FROM  customer_info
                WHERE TIMESTAMPDIFF(MONTH,now(),create_time)   <![CDATA[ <= ]]> 12
                AND is_del=0
                GROUP BY create_time
        ) sampleInfo
        GROUP BY increaseTime
    </select>

</mapper>
