Fix planning issue when using DISTICT aggregations in HAVING clause

Planning fails with a "Multiple entries with same key" error
Add test for HAVING with DISTINCT aggregations
Fix division by zero in some aggregations

Fix both VarianceAggregation and ApproximateAverageAggregation