Member-only story
HackerRank SQL Problems and Solutions —2
Problem 1
Query a list of CITY and STATE from the STATION table.
The STATION table is described as follows:

Where LAT_N is the northern latitude and LONG_W is the western longitude.
Query
SELECT CITY, STATE
FROM STATION
Output
Acme LA
Addison MI
Agency MO
Aguanga CA
Alanson MI
Alba MI
Albany CA
Albion IN
Algonac MI
Aliso Viejo CA
Allerton IA
Alpine AR
Alton MO
Amazonia MO
Amo IN
Andersonville GA
Andover CT
Anthony KS
Archie MO
Arispe IA {-truncated-}
Problem 2
Query a list of CITY names from STATION for cities that have an even ID number. Print the results in any order, but exclude duplicates from the answer.
Query
SELECT DISTINCT CITY
FROM STATION
WHERE MOD(ID, 2) = 0
Output
Aguanga
Alba
Albany
Amo
Andersonville
Archie
Athens
Atlantic Mine
Bainbridge
Baker
Bass Harbor
Bayville
Beaufort
Bellevue
Benedict
Bennington
Bentonville
Biggsville
Bison
Bono {-truncated-}
Problem 3
Find the difference between the total number of CITY entries in the table and the…