Oracle
- 1 ответ
- 0 вопросов
1
Вклад в тег
select *
from (
select sum(quantity) over (partition by path_) quantity,
row_number() over (partition by path_) rn
--,h.*, p.*, r.*
from (
SELECT cid, par_cid, rname,
sys_connect_by_path(cid,'/') path_,
sys_connect_by_root(cid) product_cid
FROM catalog
START WITH cid in (
-- возможно есть способ определить листья
-- без использования дополнительного вызова
select distinct rcid from products
)
CONNECT BY PRIOR par_cid = cid
) h
join products p on (h.product_cid = p.rcid)
join records r ...
)
where rn = 1