题目
方法一
with t as ( select C.Name,count(*) c from Vote V left join Candidate C on V.CandidateId=C.id group by C.Name ) select t.Name from t where t.c=(select max(c) from t) limit 1;
方法二
select Name from Candidate c inner join Vote v on c.id = v.CandidateId group by c.Name order by count(v.id) desc limit 1;
可以在order by 后面使用聚合函数。方法二值得学习!