我需要SQL的帮助...我想知道是否有可能找到拥有最多球队的国家……(如果一个国家的车队中至少有一名该国家的车手,那么它就有一个车队)……
f1 driver ( id_driver , driver_name , team , country ) 我设法写出了命令,告诉我每个国家的球队数量(我想这是对的)……我不明白如何以及在哪里使用'max‘命令...你能帮帮我吗?
SELECT (country) ,count(team)
FROM driver
GROUP BY country;发布于 2021-01-29 00:03:26
在该解决方案中,您不需要max,只需要对结果进行排序:
SELECT (country) ,count(distinct team)
FROM driver
GROUP BY country
order by count(distinct team) DESC如果你想要拥有最多球队的国家:
SELECT (country) ,count(distinct team)
FROM driver
GROUP BY country
order by count(distinct team) DESC
LIMIT 2https://stackoverflow.com/questions/65940733
复制相似问题