Propagate stadistinct through GROUP BY/DISTINCT in subqueries and CTEs

Propagate stadistinct through GROUP BY/DISTINCT in subqueries and CTEs

Edit