SELECT DATE_FORMAT(item_pub_date,"%Y-%m") AS dates, SUM(CASE WHEN item_classify = 0 THEN 1 ELSE 0 END) AS 0_itemCount, SUM(CASE WHEN item_classify = 0 THEN mount_file ELSE 0 END) AS 0_dzCount, SUM(CASE WHEN item_classify = 1 THEN 1 ELSE 0 END) AS 1_itemCount, SUM(CASE WHEN item_classify = 1 THEN mount_file ELSE 0 END) AS 1_dzCount, SUM(CASE WHEN item_classify = 5 THEN 1 ELSE 0 END) AS 5_itemCount, SUM(CASE WHEN item_classify = 5 THEN mount_file ELSE 0 END) AS 5_dzCount FROM tb_item <where> <if test="obj.startItemPubDate != null and obj.startItemPubDate != ''"> and DATE_FORMAT(item_pub_date,"%Y-%m") >= #{obj.startItemPubDate} </if> <if test="obj.endItemPubDate != null and obj.endItemPubDate != ''"> and DATE_FORMAT(item_pub_date,"%Y-%m") <= #{obj.endItemPubDate} </if> </where> GROUP BY DATE_FORMAT(item_pub_date,"%Y-%m") ORDER BY DATE_FORMAT(item_pub_date,"%Y-%m") DESC