赞
踩
- select aaa.MONTH as name,
- ifnull(b.count, 0) as value
- from
- ( select DATE_FORMAT(CURDATE(), '%m') as MONTH
- union select DATE_FORMAT(CURDATE() - interval 1 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 2 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 3 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 4 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 5 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 6 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 7 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 8 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 9 month, '%m')
- union select DATE_FORMAT(CURDATE() - interval 10 month, '%m') ) aaa
- left join
- ( select DATE_FORMAT(f.create_time, '%m') as NAME, count(1) as count from busi_res_carbon f
- where year(f.create_time) = 2023 and is_delete = 0
- group by DATE_FORMAT(f.create_time, '%m') ) b
- on aaa.MONTH = b.NAME
- order by aaa.MONTH
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。