( FOR $m IN DISTINCT document("items.xml")//item_tuple/month(end_date) LET $item := document("items.xml") //item_tuple[year(end_date) = 1999 AND month(end_date) = $m] RETURN $m , count($item) SORTBY (month) )