我需要一个具有最大值的字符串

I need one string with max value

我有这样的需求:

SELECT s_name, count(Mark)
FROM specialty
join interns_specialty on specialty.specialty_id = interns_specialty.specialty_id
join practice_result on practice_result.Intern_id = interns_specialty.intern_id
where Mark=5
group by specialty.specialty_id
ORDER by count(Mark) DESC;

That is what i get from my quire, i need to take the row with the max count of excellent marks, if there is two or more such rows, i must to get it all 我需要获得一个带有专业名称的字符串,该字符串比其他字符串具有更高的分数。 但是我不能t understand how to do this. I tried to use "Limit", but if i have two or more specialties - it will be work incorrect. I couldn不能将 MAX 与其他聚合函数一起使用,所以我需要一个建议。

我想你想要 rank():

SELECT m.*
FROM (SELECT s.s_name, COUNT(*),
             RANK() OVER (ORDER BY COUNT(*) DESC) as seqnum
      FROM specialty s JOIN
           interns_specialty ins
           ON s.specialty_id = ins.specialty_id JOIN
           practice_result pr
           ON pr.Intern_id = ins.intern_id
      WHERE Mark = 5
      GROUP BY s.specialty_id
     ) m
WHERE seqnum = 1;