I have a table like this. All I want in country Name, Population number and if the population in MAX then label MAX and similarly for MIN. I have written below query in SQL Server using the CASE
statement.
/* MIN/MAX Population amongst the countries */
SELECT
country, population,
CASE
WHEN population == MIN(population) THEN "MIN"
WHEN population == MAX(population) THEN "MAX" ELSE "NA"
END as "pop_stats"
FROM
countries_by_population;