Remove duplicate values from queries