SELECT T1.name,T1.buyAmount,T2.sellAmount FROM(SELECT A.name,SUM(buyAmount) FROM A GROUP BY A.name) T1 LEFT JOIN(SELECT B.name,SUM(sellAmount) FROM B GROUP BY B.name) T2ON T1.name=T2.name答案应该是这样子。先统计后联接