Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSQLself-joinsSingle-choice MCQ

This self-join finds pairs of employees in the same department. What is the purpose of the `a.id < b.id` predicate?

SELECT a.name, b.name FROM employees a JOIN employees b ON a.dept_id = b.dept_id AND a.id < b.id;