beecrowd SQL

Second Largest and Smallest

Gustavo Moraes BR Brasil

Timelimit: 1

Find the city with the second largest population and then the city with the second smallest population.

Scheme

cities
Column Type
id numeric
city_name varchar(50)
population numeric

Tables

cities
id city_name population
1 São Paulo 12396372
2 Rio de Janeiro 6775561
3 Brasília 3094325
4 Salvador 2900319
5 Fortaleza 2703391
6 Belo Horizonte 2530701
7 Manaus 2255903
8 Curitiba 1963726
9 Recife 1661017
10 Goiânia 1555626
11 Belém 1506420
12 Porto Alegre 1492530

Output Sample

city_name population
Rio de Janeiro 6775561
Belém 1506420