select re.`Customer Name`,re.sum_val from( SELECT c2.NAME as "Customer Name",sum(c.bal) as sum_val FROM Card as c left join Customer as c2 on c.ID = c2.ID where c2.CITY = "beijing" GROUP BY c.ID ) as re where re.sum_val = ( SELECT max(sum_value) from( SELECT sum(c3.bal) as sum_value FROM Card as c3 left join Customer as c4 on c3.ID = c4.ID where c4.CITY = "beijing" GROUP BY c3.ID ) as t1 )
最后一道sql题,这么写应该就没错了吧?有没有做出来的大佬?
全部评论
(8) 回帖