I have a table with schema and data as follows
id,winner,season
1, Chelsea, 2014
2, Chelsea, 2014
3, Chelsea, 2015
4, Arsenal, 2014
. .
and so on.
Basically, there is an entry in there for every match of every season.
I need to query and identify the team that won the maximum number of matches for each season.
I got till retrieving the maximum number of matches in each season but I am not able to retrieve the name of the team that had the maximum. Any leads?
with t1 as
(select count(winner) as cnt, winner, season from matches group by winner,season)
select max(cnt),season from t1 group by season