问题是使用*(因为您正在使用分组依据)。另外,SUM(shop_time)被乘以香蕉中的尽可能多的行,因此得到202(香蕉中的两行)
试试这个查询:
SELECt tt.shop_name, SUM(shop_time)AS shoptime, Ifnull(banana_amount, 0) AS bananas FROM shop tt LEFT OUTER JOIN (SELECt banana_person, SUM(banana_amount) AS banana_amount FROM bananas GROUP BY banana_person) tz ON tt.shop_name = tz.banana_person GROUP BY shop_name;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)