Skip to main content
All Problems
medium0% acceptance

Doctor Pairs in the Same Department

Administration wants to list all pairs of doctors who work in the same department. Return doctor1_name, doctor2_name, and department_id. Ensure each pair appears only once (doctor1 id < doctor2 id). Order by department_id, doctor1_name.

Schema

🔑idINT
first_nameTEXT
last_nameTEXT
specialtyTEXT
🔗department_idINT
emailTEXT
phoneTEXT
hire_dateTEXT
salaryREAL
postgresql

Run your query to see results

Press Ctrl + Enter to execute