{ for $person in //person let $pets_value := sum($person//pets:price) let $devs_value := sum($person//devs:price) where $pets_value > 100000 or $devs_value > 150000 return {$devs_value} {$pets_value} }