题目链接:点击打开链接
题目大意:略。
解题思路:略。
AC 代码
--解决方案(1) SELECTDISTINCTemployee_idFROM ( SELECTemployee_idFROMEmployeesWHEREmanager_id=1UNIONALLSELECTemployee_idFROMEmployeesWHEREmanager_idIN ( SELECTemployee_idFROMEmployeesWHEREmanager_id=1 ) UNIONALLSELECTemployee_idFROMEmployeesWHEREmanager_idIN ( SELECTemployee_idFROMEmployeesWHEREmanager_idIN ( SELECTemployee_idFROMEmployeesWHEREmanager_id=1 ) ) ) TWHEREemployee_id!=1--解决方案(2) SELECTe1.employee_idFROMEmployeese1JOINEmployeese2ONe1.manager_id=e2.employee_idJOINEmployeese3ONe2.manager_id=e3.employee_idWHEREe1.employee_id!=1ANDe3.manager_id=1--解决方案(3) WITHt1AS(SELECTemployee_idFROMEmployeesWHEREmanager_id=1), t2AS(SELECTemployee_idFROMEmployeesWHEREmanager_idIN (SELECT*FROMt1)), t3AS(SELECTemployee_idFROMEmployeesWHEREmanager_idIN (SELECT*FROMt2)) SELECT*FROMt2WHEREemployee_id<>1UNIONSELECT*FROMt3WHEREemployee_id<>1