Query 5 updated to group contracts by managing department