Select parent rows and include cost of children

For a one-level parent/children relationship, as shown in your sample data, I would recommend:

    coalesce(parent, wonum) wonum
    sum(actlabcost)  actlabcost, 
    sum(actmatcost)  actmatcost,
    sum(actservcost) actservcost,
    sum(acttoolcost) acttoolcost
from workorder wo
group by coalesce(parent, wonum)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top