子查询ORA-00907:缺少右括号

时间:2019-01-11 21:36:59

标签: sql oracle oracle11g

执行下面的查询时,我收到以下错误消息

错误消息:

  

ORA-00907:缺少右括号

错误消息指向以下子查询

错误是由

引起的
SELECT t4.TIN FROM table4 t4, table5 TRA WHERE .... ORDER BY t4.TIN ASC

我目前在查询方面并不擅长,希望有人能指出我在做什么错。

查询

SELECT 
    t1.TIN AS "Employee TIN", 
    t2.NAME AS "Employer Name", 
    MAX(t3.SUMMARY_NUM) AS "Summary Number"
FROM 
    table1 t1, 
    table2 t2, 
    table3 t3
WHERE 
    t1.SUMMARY_YEAR = 2017
    AND t2.TIN = t1.TIN
    AND t3.SUMMARY_NUM = t1.SUMMARY_NUM 
    AND t3.TIN IN(SELECT t4.TIN FROM table4 t4, table5 TRA WHERE .... ORDER BY t4.TIN ASC)
GROUP BY t2.NAME, t1.TIN
ORDER BY t1.TIN ASC

1 个答案:

答案 0 :(得分:2)

从{p>删除ORDER BY

(SELECT t4.TIN FROM table4 t4, table5 TRA WHERE .... ORDER BY t4.TIN ASC)

插图:

SQL> select count(*) from emp
  2  where deptno in (select deptno from dept order by dname);
where deptno in (select deptno from dept order by dname)
                                         *
ERROR at line 2:
ORA-00907: missing right parenthesis


SQL> select count(*) from emp
  2  where deptno in (select deptno from dept);

  COUNT(*)
----------
        14

SQL>