ORA-00907:代码底部缺少右括号 - 为什么?语法很好

时间:2013-12-08 10:57:46

标签: sql oracle select

select racuni.str_id
  from racuni
  where racuni.str_id in
                   (select racuni.str_id
                      from racuni 
                           join stavke
                           on (racuni.racuni_id = stavke.rcn_id)
                     group by racuni.str_id
                     order by sum(stavke.iznos_kamate) desc
                    )
    and rownum = 1;

1 个答案:

答案 0 :(得分:1)

您必须首先在最里面的查询中执行订单,然后选择内部查询中的第一行,然后在外部查询中获取该racun。像这样:

select racuni.*
from   racuni
where  racuni.str_id in
             (select str_id
              from
               (select racuni.str_id
                  from racuni 
                       join stavke
                       on (racuni.racuni_id = stavke.rcn_id)
                 group by racuni.str_id
                 order by sum(stavke.iznos_kamate) desc )
               where rownum = 1 );