Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong result when select count/sum(distinct ) from int_col union all decimal_col #9900

Closed
XuHuaiyu opened this issue Mar 26, 2019 · 1 comment · Fixed by #9901 or #9913
Closed

wrong result when select count/sum(distinct ) from int_col union all decimal_col #9900

XuHuaiyu opened this issue Mar 26, 2019 · 1 comment · Fixed by #9901 or #9913
Assignees
Labels
type/bug The issue is confirmed as a bug.

Comments

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Mar 26, 2019

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
CREATE TABLE `t` (
  `a` int(11) DEFAULT NULL,
  `b` decimal(6,3) DEFAULT NULL
);

insert into t values(1, 1.000);
  1. What did you expect to see?
select count(distinct a) from (select a from t1 union all select b from t1) tmp;

+-------------------+
| count(distinct a) |
+-------------------+
|                 1 |
+-------------------+
  1. What did you see instead?
select count(distinct a) from (select a from t1 union all select b from t1) tmp;

+-------------------+
| count(distinct a) |
+-------------------+
|                 2 |
+-------------------+
  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
Release Version: v3.0.0-beta-279-g5025d582a
Git Commit Hash: 5025d582a7a69ac9c2f6f8ed744aa23ce687d433
Git Branch: master
UTC Build Time: 2019-03-26 08:35:47
GoVersion: go version go1.12 darwin/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false
@XuHuaiyu
Copy link
Contributor Author

sum also meets this problem

tidb>  select sum(distinct b) from (select b from t union all select a from t) tmp ;

+-----------------+
| sum(distinct b) |
+-----------------+
|           2.000 |
+-----------------+
1 row in set (0.00 sec)

@XuHuaiyu XuHuaiyu changed the title wrong result when select count(distinct ) from int_col union all decimal_col wrong result when select count/sum(distinct ) from int_col union all decimal_col Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The issue is confirmed as a bug.
Projects
None yet
1 participant