PL / SQL:ORA-06550:此处不允许使用组功能

时间:2018-08-19 07:21:53

标签: oracle plsql group-by having-clause

我遇到以下错误

enter image description here

使用此代码

<p class="button"><a href="{% url 'suub' %}">Next</a></p>

1 个答案:

答案 0 :(得分:1)

应该是

DECLARE 
  v_manager_id NUMBER;
BEGIN
  SELECT MANAGER_ID 
  INTO v_manager_id
  FROM DEPARTMENTS
  GROUP BY MANAGER_ID
  HAVING COUNT(MANAGER_ID) > 1;
END;

或者,如果您需要count(manager_id)的值,则必须声明一个变量,例如

DECLARE 
  v_manager_id NUMBER;
  v_count      NUMBER
BEGIN
  SELECT MANAGER_ID, COUNT(MANAGER_ID)
  INTO v_manager_id, v_count
  FROM DEPARTMENTS
  GROUP BY MANAGER_ID
  HAVING COUNT(MANAGER_ID) > 1;
END;