Maximum count in SQL -
i have schema of players in league looks schema below.
player (playerid integer, mentorid integer, leagueid integer, pay integer) league (leagueid integer, leaguename text)
i trying find leagues have maximum number of players , solution should consider scenario having more 1 leagues have maximum number of players result should have - leaguename, count of players sorted leaguename.how that?
with x ( select l.leaguename, count(distinct p.playerid) player_count player p join league l on p.leagueid = l.leagueid group l.leaguename) , y (select max(player_count) player_count x) select x.leaguename, y.player_count x join y on x.player_count = y.player_count order x.leaguename
Comments
Post a Comment