<?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.yeejoin.amos.boot.module.jxiop.biz.mapper2.CommonMapper">

    <select id="selectAgo10Month" resultType="map">
        WITH RECURSIVE month_sequence AS (
        SELECT 0 AS num
        UNION ALL
        SELECT num + 1 FROM month_sequence WHERE num &lt; 9
        )
        SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL (num + 1) MONTH), '%Y-%m') AS MonthYear
        FROM month_sequence
        ORDER BY MonthYear DESC;
    </select>

    <select id="selectLast3Month" resultType="map">
WITH RECURSIVE month_sequence AS (
        SELECT 0 AS num
        UNION ALL
        SELECT num + 1 FROM month_sequence WHERE num &lt; 2
        )
        SELECT DATE_FORMAT(DATE_SUB(NOW(), INTERVAL -(num ) MONTH), '%Y-%m') AS MonthYear
        FROM month_sequence
        ORDER BY MonthYear ASC;
    </select>



</mapper>
