select a.time time, a.total total from( select concat(year(t_time),"-",LPAD(MONTH(t_time),2,0)) time,year(t_time) year, month(t_time) month,sum(t_amount) total from customer left join trade on trade.t_cus=customer.c_id where c_name="Tom" and ...