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;
答案 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 );