Project(Extend(Extend(AggregationJoin(Aggregation(??agg1: ?p, SAMPLE, {}, G1=Group((?p), Filter((?type = ) || (?type = ), BGP( ?s ?p ??2 . ??2 ?type)))), Aggregation(??agg2: ?p, COUNT, {}, G1)), ?p, ??agg1), ?count, ??agg2), {?p, ?count})