Select distinct collection only when joins present