Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
The very basics
Infinite looping
Processing graphs with recursive CTEs
26. Traveling salesman 1


That was quite an impressive query, wasn't it? Let's build it again, step by step.


We start in London, so let's show the information for London first. We need the following columns:

  • path – For now, it's simply the city name.
  • lat.
  • lon.
  • total_distance – The total distance travelled between cities; for now, it's equal to 0.0.
  • count_places – The number of cities visited; for now, it's equal to 1.

All the information can be found in the table city.