不确定为什么它一直说缺少右括号,它强调了(*)处的错误。请帮忙,谢谢。
SELECT FIRST, LAST
FROM OFFICERS
WHERE OFFICER_ID IN (SELECT OFFICER_ID FROM CRIME_OFFICERS COUNT(*) as TotalReportsOfficer
GROUP BY OFFICER_ID
HAVING TotalReportsOfficer > ((SELECT COUNT(CRIME_ID) from CRIME_OFFICERS))/ (SELECT COUNT(OFFICER_ID) from OFFICERS));
错误:ORA-00907:缺少右括号 00907. 00000 - “缺少右括号” *原因:
*动作:行错误:3列:66
更新: 我想找出每位官员所拥有的报告数量,然后比较每一位官员,以找出哪些人员的数量大于平均报告数量。
答案 0 :(得分:0)
嗨,您可以使用以下查询
SELECT OF.FIRST, OF.LAST FROM OFFICERS OF
INNER JOIN (SELECT OFFICER_ID, COUNT(*) AS TotalReportsOfficer FROM OFFICERS
GROUP BY CRIME_OFFICERS) COF
ON (OF1.OFFICER_ID =COF.OFFICER_ID )
HAVING COF.TotalReportsOfficer > ((SELECT COUNT(CRIME_ID) from CRIME_OFFICERS)/(SELECT COUNT(OFFICER_ID) from OFFICERS))
答案 1 :(得分:-1)
因为你在FROM之后有COUNT(*);这不是Oracle SQL语法(或者,实际上是任何SQL语法)。
如果你想分享这个查询的目的(你用简单的英语想要做什么),也许我们可以帮助你找到一个有效的解决方案。你想在那里做什么?