Eng 6436 distinct reroute

This is the fast, simple but not the best efficient solution for DISTINCT with GROUP BY cases. We will create tickets to optimize it later.
Same comment here, and in basic-select: try something other than LIMIT 1 to really use DISTINCT.