0

当我运行此查询时:

(SELECT MAX(
  SELECT 
    COUNT(e4.employee_id) 
  FROM 
    employees e4, 
    departments d2 
  WHERE 
    d2.manager_id = e3.employee_id AND
    e4.department_id = d2.department_id
  ) 
FROM 
  employees e3
)

我得到一个 ORA-00936:缺少表达式。不知道哪里错了。

4

2 回答 2

1

一个更简单的解决方案:

SELECT
    MAX(COUNT(*))
FROM
    employees
GROUP BY
    manager_id
于 2012-11-09T03:20:34.190 回答
1

我的朋友告诉我如何更改此查询。我的查询试图返回一位经理拥有的最大员工数。

我是 SQL 新手,我正在编写长查询:) 正确的是:

SELECT
    MAX(counter)
FROM
(SELECT
    COUNT(*) AS counter
FROM
    employees e
    GROUP BY
    e.manager_id)
于 2012-11-09T00:55:10.517 回答