查找比其他任何主管监督更多员工的员工姓名的SQL查询是什么?
Employee
+----------+-----------+-----------+
| Fname | Ssn | Super_ssn |
+----------+-----------+-----------+
| John | 123456789 | 333445555 |
| Franklin | 333445555 | 888665555 |
| Alicia | 999887777 | 987654321 |
| Jennifer | 987654321 | 888665555 |
| Ramesh | 666884444 | 333445555 |
| Joyce | 453453453 | 333445555 |
| Ahmad | 987987987 | 987654321 |
| James | 888665555 | NULL |
+----------+-----------+-----------+
这是我尝试过的事情
SELECT Fname
FROM Employee
WHERE Super_ssn >=ALL(Select Super_ssn
FROM Employee)
答案 0 :(得分:1)
最简单的方法就是按员工人数列出:
SELECT Supervisor_ssn, COUNT(SSN) as n
FROM Employee
GROUP BY Supervisor_ssn
ORDER BY n DESC
你想要的那个将登上榜首。
希望有所帮助
答案 1 :(得分:0)
试试这个。如果您想要由最多或最少监督的人员排序,请删除LIMIT 1条款
re.split('\s+(?=[A-Z])', "Trip HopDowntempoSynth-pop")
# ['Trip', 'HopDowntempoSynth-pop']