select
[Table A].Class
, [Table A].Name
,SUM(Items) as total_tiems
from [Table A]
Left Join [Table B]
on [Table A].Name=[Table B].Name
GROUP BY [Table A].Class, [Table A].Name
你少 group by Class,A.Name
還有left join的別名只有A和B沒有多Table的字
select Class,A.Name,SUM(Items) as total_tiems
from Table A
Left Join Table B on A.Name = B.Name
group by Class,A.Name
除非是這樣的..表格名有空白
select Class,[Table A].Name,SUM(Items) as total_tiems
from [Table A]
Left Join [Table B] on [Table A].Name = [Table B].Name
group by Class,[Table A].Name
SUM函數後面要寫GROUP BY 欄位名,才知道要用什麼欄位來統計
SELECT A.Class, A.Name, SUM(B.Items) as total_tiems
FROM Table A
LEFT JOIN Table B
ON A.Name = B.Name
GROUP BY A.Class, A.Name