select date_format(t_time,'%Y-%m')  as time, sum(t_type*t_amount) as total
from  trade
where t_cus in
(select c_id 
from customer
where c_name = 'Tom') and year(t_time) = 2023 and t_type = 1
group by date_format(t_time,'%Y-%m')
order by date_format(t_time,'%Y-%m')

这道题也是道烂题 调试不通过用例的时候 会发现有个用例, t_type是2 ,所以会导致

sum(t_type*t_amount)as total 会报错

所以得必须补一个 t_type = 1