select time,sum(t_amount) as total from 
(
select date_format(t_time,'%Y-%m') as time,t_cus,t_type,t_amount,c_name from trade as t
join
(
select c_id,c_name from customer
) as c
on t.t_cus = c.c_id
where c_name = 'Tom' and date_format(t_time,'%Y') = 2023 and t_type = 1
) as t1
group by time
order by time