Project(Extend(Extend(Extend(AggregationJoin(Aggregation(??agg1: ?pid, SAMPLE, {}, G1=Group((?pid, ?cond), Join(ToMultiSet({{(?pid, )}, {(?pid, )}, {(?pid, )}, {(?pid, )}, {(?pid, )}}), Extend(Extend(BGP( ?oid ?pid . ?oid ?price . ?oid ?cond), ?newOid1, if((?cond = 1), ?oid, ) ), ?newOid0, if((?cond = 0), , ?oid) )))), Aggregation(??agg2: ?newOid0, SAMPLE, {}, G1), Aggregation(??agg3: ?newOid1, SAMPLE, {}, G1)), ?pid, ??agg1), ?oidAs0, ??agg2), ?oidAs1, ??agg3), {?pid, ?oidAs0, ?oidAs1})