Sql ORA000907:缺少右括号

Sql ORA000907:缺少右括号,sql,oracle,subquery,Sql,Oracle,Subquery,运行此查询时: select prnt_c_fam_id as PRNT_C_FAM_ID3, min(ptel_d_redet_due) as Date_DUE from ptel t where ptel_d_redet_due > (select max(rest_d) from rest where prnt_c_fam_id = t.prnt_c_fam

运行此查询时:

select prnt_c_fam_id as PRNT_C_FAM_ID3, min(ptel_d_redet_due) as Date_DUE
  from ptel t
 where ptel_d_redet_due > (select max(rest_d)
                             from   rest 
                            where  prnt_c_fam_id = t.prnt_c_fam_id
                              and rest_c in ('RS'))
group by prnt_c_fam_id 
order by prnt_c_fam_id
查询成功返回。在其周围添加括号时:

(select prnt_c_fam_id as PRNT_C_FAM_ID3, min(ptel_d_redet_due) as Date_DUE
   from ptel t
  where ptel_d_redet_due > (select max(rest_d)
                             from   rest 
                            where  prnt_c_fam_id = t.prnt_c_fam_id
                              and rest_c in ('RS'))
 group by prnt_c_fam_id 
 order by prnt_c_fam_id)

我得到了ORA00907:错过了正确的错误。有人知道为什么吗?(注意:此查询需要括号,因为它成为较大查询的from子句中的子查询。其他子查询在单独运行时使用和不使用括号)。

如果将其用作子查询,请删除order by子句。子查询应如下所示

      (
       select prnt_c_fam_id as PRNT_C_FAM_ID3, min(ptel_d_redet_due) as Date_DUE
       from ptel t
       where ptel_d_redet_due > (select max(rest_d)
       from   rest 
       where  prnt_c_fam_id = t.prnt_c_fam_id
       and rest_c in ('RS'))
       group by prnt_c_fam_id 
      )

谢谢VJ。这解决了问题,但在查询中引入了另一个问题,我们现在必须弄清楚。