题解 | 获取指定客户每月的消费额
select date_format(t_time,'%Y-%m') as time, sum(t_amount) as total from ( select t_time, t_cus as c_id, t_type, t_amount from trade )t1 left join customer using(c_id) where c_name = 'Tom' and year(t_time) = '2023' and t_type = 1 group by 1 order by 1