Challenge: Search for the Nearest Circuits

Try a hands-on exercise to test your understanding of SQL clauses and available functions in PostgreSQL.

Problem statement

Here is a table for circuits. The data in the circuits table looks like the following:

-[ RECORD 1 ]----------------------------------------------------------
circuitid  | 1
circuitref | albert_park
name       | Albert Park Grand Prix Circuit
location   | Melbourne
country    | Australia
lat        | -37.8497
lng        | 144.968
alt        | 10
url        |

Write a query to find the five nearest circuits to Paris, France. You need to retrieve the information present in the following columns:

  • name
  • location
  • country

Here are the values of geographic points that you will need:

Longitude: 2.349014

Latitude: 48.864716

Get hands-on with 1200+ tech skills courses.