intermediateJOINs — INNER, LEFT, RIGHT, FULL, SELF, CROSS

When would you use a SELF JOIN vs a CTE?

SELF JOIN: use for comparing rows within the same table (finding duplicates, adjacent rows, hierarchies). Example: employees with their managers. Simple, single-level comparisons. CTE with recursive: use for arbitrary-depth hierarchies (org charts, category trees, bill of materials). SELF JOIN can only do 1 level at a time; recursive CTE can traverse unlimited depth. Example: finding all subordina

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.

When would you use a SELF JOIN vs a CTE?

Next Step

Continue to You need a report showing all employees and their total order amounts this year. Employees with no orders should show 0. How do you write this?← Back to all SQL questions