Eng 6436 distinct reroute

This is incorrect handling of the case when groupByElement == null and havingElement != null or any case where the statement has aggs. Those cases are table aggs with a single row result -- m_distinct should be set to false (can just be ignored) but adding groupByElement will corrupt the query.