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


Fine work! Let's do one more exercise. This time, you'll have to write the query from scratch. Before you proceed to writing the query, you'll have to learn a 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,
  • PartOf – the ID of the department one level up.