[PD-457] Sorting fix

Just wrapped the results in a set to remove duplicates. Originaly went for a more efficient query, but technical constraints prevented that version from panning out.