I have the following table from a factory database called world
in MySQL Workbench:
Table: country
Relevant Columns:
Code char(3) PK,
IndepYear smallint(6)
I'd like to get the year (or possibly years) when the most countries have become independent. I don't want to list anything else just the year(s), one row per year.
EDIT:
I have found the right solution that actually works.
SELECT IndepYear
FROM (SELECT IndepYear,
COUNT(IndepYear) AS Years
FROM world.country
GROUP BY IndepYear
ORDER BY Years DESC) AS T1
WHERE Years IN (SELECT Years
FROM (SELECT IndepYear,
COUNT(IndepYear) AS Years
FROM world.country
GROUP BY IndepYear
ORDER BY Years DESC
LIMIT 1) AS T2
GROUP BY IndepYear)
ORDER BY IndepYear ASC;