Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
The very basics
Infinite looping
Processing graphs with recursive CTEs
Summary
35. Exercise 3

Instruction

Excellent! The last problem deals with graphs.

Exercise

We want to travel between the four cities presented in the table destination. We'll be starting from Warsaw. We have another table called ticket that lists all possible flight connections between these cities.

Your task is to find the cheapest path in terms of total ticket cost. List all paths starting in Warsaw which go through all four cities. Order the paths by descending total_cost.

In your answer, provide the following columns:

  • path – City names, separated by '->'.
  • last_id – The ID of the last city.
  • total_cost – The total cost of tickets.
  • count_places – The number of places visited; it should equal 4.