Select attributes from parent rows (and include cost of children)

You can use aggregation:

select coalesce(parent, wonum) as wonum,
       max(case when parent is null then classification end) as classification,
       sum(ACTLABCOST) as ACTLABCOST,
       sum(ACTMATCOST) as ACTMATCOST
from t
group by coalesce(parent, wonum);

This seems simple enough to me.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top