Adding missing DISTINCT keywords to select queries in queue record