( FOR $i IN document("items.xml")//item_tuple LET $b := document("bids.xml")//bid_tuple[itemno=$i/itemno] WHERE count($b) >= 50 RETURN $i/itemno, $i/description, count($b) , max($b/bid_amount) SORTBY(high_bid) DESCENDING )