Eng 6436 distinct reroute

My comment above changes this comment "converted to group by all columns in the select list if no GROUP BY is present" is only one special case. TO make it general, you can add " or is optimized out".