Query:
```sql
SELECT round(avg(log(2) * number), 6) AS k FROM numbers(10000000)
GROUP BY (number % 2) * (number % 3), number % 3, number % 2
HAVING avg(log(2) * number) > 3465735.3 ORDER BY k
SETTINGS allow_experimental_analyzer=1, optimize_group_by_function_keys=0;
```
Output:
```
Ok.

0 rows in set. Elapsed: 0.079 sec. Processed 10.01 million rows, 80.06 MB (127.02 million rows/s., 1.02 GB/s.)
```

Query:
```sql
SELECT round(avg(log(2) * number), 6) AS k FROM numbers(10000000)
GROUP BY (number % 2) * (number % 3), number % 3, number % 2
HAVING avg(log(2) * number) > 3465735.3 ORDER BY k
SETTINGS allow_experimental_analyzer=0, optimize_group_by_function_keys=0;
```

Output:
```
┌──────────────k─┐
│   3465735.9028 │
│   3465735.9028 │
│ 3465736.595947 │
└────────────────┘

3 rows in set. Elapsed: 0.085 sec. Processed 10.01 million rows, 80.06 MB (117.56 million rows/s., 940.52 MB/s.)
```

cc @kitaisreal 
const auto & left_argument_constant_value_literal = left_argument_constant_node->getValue();
            if (!function_name_if_constant_is_negative.empty() &&
                left_argument_constant_value_literal < zeroField(left_argument_constant_value_literal))
            {
                resolveAggregateFunctionNode(*aggregate_function_node, function_name_if_constant_is_negative);
            }
            auto inner_function = aggregate_function_arguments_nodes[0];
            auto inner_function_right_argument = std::move(inner_function_arguments_nodes[1]);
            aggregate_function_arguments_nodes = {inner_function_right_argument};
            inner_function_arguments_nodes[1] = node;
            node = std::move(inner_function);
        }
        else if (right_argument_constant_node)
        {
            
            const auto & right_argument_constant_value_literal = right_argument_constant_node->getValue();
            if (!function_name_if_constant_is_negative.empty() &&
                right_argument_constant_value_literal < zeroField(right_argument_constant_value_literal))
            {
                resolveAggregateFunctionNode(*aggregate_function_node, function_name_if_constant_is_negative);
            }
            auto inner_function = aggregate_function_arguments_nodes[0];
            auto inner_function_left_argument = std::move(inner_function_arguments_nodes[0]);
            aggregate_function_arguments_nodes = {inner_function_left_argument};
            inner_function_arguments_nodes[0] = node;
            node = std::move(inner_function);
        }
    }
private:
    static inline void resolveAggregateFunctionNode(FunctionNode & function_node, const String & aggregate_function_name)