Added 'DISTINCT' to subquery, handling multiple sections