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


Good stuff! Let's do one more exercise. This time, you'll write the query from scratch. Before you start, let's first check out the new table.


Instead of employees, we're now going to deal with departments from the table department.

Select all data from the table. It contains the following columns:

  • id – The ID of each department.
  • name – The name of the department.
  • part_of – The ID of the department one level up.