我有一张table:
|eid |ManagerID|Phone#|(other details..|
|------|---------|------|----------------|
|1001 |1004 |12345 |......... |
|1002 |1004 |1233 |......... |
|1003 |1006 |133 |......... |
|1004 | |444 |......... |
|1005 |1004 |555 |......... |
|1006 | |666 |......... |
等等
我试图显示管理最多员工的经理的所有字段。
我有
SELECT *
FROM EMPLOYEE
GROUP BY Manager
HAVING COUNT (Manager)=(
SELECT MAX(theCount) AS theCount
FROM (
SELECT Manager, COUNT(Manager) theCount
FROM EMPLOYEE
GROUP BY Manager));
但不断出现错误:
Incorrect syntax near ')'.
我不知道为什么。
我知道这一部分的作用是给出一个包含经理人数的表格:
SELECT Manager, COUNT(Manager)
AS theCount
FROM EMPLOYEE
GROUP BY Manager
2条答案
按热度按时间qcbq4gxm1#
wwtsj6pe2#
你可以试试下面的-
演示
输出: