WITH RankedExpenditure AS (
SELECT
country,
year,
military_expenditure_current_usd,
RANK() OVER (PARTITION BY year ORDER BY military_expenditure_current_usd DESC) AS rank
FROM
"@kaggle.prasertk_military_expenditure_by_country_from_19702020.military_expenditure"
WHERE
country NOT IN ('High Income','High income', 'Post-demographic dividend', 'OECD members', 'World', 'Europe & Central Asia')
)
SELECT
country,
year,
military_expenditure_current_usd
FROM
RankedExpenditure
WHERE
rank = 3
ORDER BY
year DESC;