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

  

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-27
  • 2022-01-26
  • 2021-08-01
  • 2022-12-23
猜你喜欢
  • 2021-08-02
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2019-05-22
相关资源
相似解决方案