select date_format(month,'%Y-%m'), sum(t1.g1) as GMV
from
(select event_time as month, sum(total_amount) g1
from tb_order_overall
where status = 0 and year(event_time) = 2021
group by month
union
select event_time as month, sum(total_amount) g1
from tb_order_overall
where status = 1 and year(event_time) = 2021
group by month
order by month) t1
group by date_format(month,'%Y-%m')
having GMV > 100000
order by GMV
按月分组,先查出当月的付款总数,再用union连接当月未付款的总数得到一张有付款总数和未付款总数的表

京公网安备 11010502036488号