pingcap / pingcap/tidb

`variance` result not same as MySQL

Open
#48,159 0 comments 0 reactions 0 assignees View on GitHub
severity/minor sig/execution type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```
create table t(a int, b bigint, c float, d double, e decimal);
insert into t values(1, 1000, 6.8, 3.45, 8.3), (1, 3998, -3.4, 5.12, 9.3),(1, 288, 9.2, 6.08, 1);
select variance(b), variance(c), variance(d), variance(e) from t group by a;
```

### 2. What did you expect to see? (Required)

```
mysql> select variance(b), variance(c), variance(d), variance(e) from t group by a;
+--------------------+--------------------+-------------------+--------------------+
| variance(b) | variance(c) | variance(d) | variance(e) |
+--------------------+--------------------+-------------------+--------------------+
| 2584338.6666666665 | 29.840000178019228 | 1.180822222222222 | 12.666666666666666 |
+--------------------+--------------------+-------------------+--------------------+
1 row in set (0.00 sec)
```

### 3. What did you see instead (Required)

```
mysql> select variance(b), variance(c), variance(d), variance(e) from t group by a;
+--------------------+--------------------+-------------------+--------------------+
| variance(b) | variance(c) | variance(d) | variance(e) |
+--------------------+--------------------+-------------------+--------------------+
| 2584338.6666666665 | 29.840000178019235 | 1.1808222222222229 | 12.666666666666666 |
+--------------------+--------------------+-------------------+--------------------+
1 row in set (0.00 sec)
```

### 4. What is your TiDB version? (Required)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.