SQL中的最大计数

时间:2015-07-21 18:28:12

标签: sql

我有一个联盟中的球员模式,看起来像下面的模式。

Player (playerid integer, mentorid integer, leagueid integer, pay integer)
League (leagueid integer, leaguename text)

我正在努力寻找拥有最多玩家数量的联赛,而且解决方案应考虑具有多个联盟的场景,这些联盟拥有最多玩家数量结果应该只有 - leaguename,按照leaguename排序的玩家数量。我怎么做到的?

2 个答案:

答案 0 :(得分:1)

with x as (
select l.leaguename, count(distinct p.playerid) as player_count 
from player p join league l on p.leagueid = l.leagueid
group by l.leaguename)
, y as (select max(player_count) player_count from x)
select x.leaguename, y.player_count
from x join y on x.player_count = y.player_count
order by x.leaguename

答案 1 :(得分:1)

你可以试试这个:

@media (max-width:600px)