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

select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t returns wrong decimal #19426

Closed
wjhuang2016 opened this issue Aug 25, 2020 · 5 comments · Fixed by #19592 or #20017
Closed
Assignees
Labels
priority/P1 The issue has P1 priority. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a int primary key, b int);
insert into t values (1, 11), (4, 44), (2, 22), (3, 33);
mysql> select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t;
+-------------------------------------------------------+
| sum(case when a <= 0 or a > 1000 then 0.0 else b end) |
+-------------------------------------------------------+
|                                                   110 |
+-------------------------------------------------------+
1 row in set (0.01 sec)

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

mysql> select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t;
+-------------------------------------------------------+
| sum(case when a <= 0 or a > 1000 then 0.0 else b end) |
+-------------------------------------------------------+
|                                                 110.0 |
+-------------------------------------------------------+
1 row in set (0.01 sec)

3. What did you see instead (Required)

mysql> select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t;
+-------------------------------------------------------+
| sum(case when a <= 0 or a > 1000 then 0.0 else b end) |
+-------------------------------------------------------+
|                                                   110 |
+-------------------------------------------------------+
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

master

@wjhuang2016 wjhuang2016 added the type/bug The issue is confirmed as a bug. label Aug 25, 2020
@wjhuang2016 wjhuang2016 changed the title select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t return wrong decimal select sum(case when a <= 0 or a > 1000 then 0.0 else b end) from t returns wrong decimal Aug 25, 2020
@time-and-fate
Copy link
Member

/label sig/execution

@ti-srebot ti-srebot added the sig/execution SIG execution label Aug 25, 2020
@lzmhhh123 lzmhhh123 self-assigned this Aug 26, 2020
@lzmhhh123
Copy link
Contributor

@dyzsr PTAL.

@dyzsr
Copy link
Contributor

dyzsr commented Aug 27, 2020

/assign @dyzsr

@qw4990 qw4990 added the priority/P3 The issue has P3 priority. Assigned to backlog. label Aug 27, 2020
@lzmhhh123 lzmhhh123 removed their assignment Aug 27, 2020
@scsldb scsldb added priority/P1 The issue has P1 priority. and removed priority/P3 The issue has P3 priority. Assigned to backlog. labels Aug 27, 2020
@jebter
Copy link

jebter commented Sep 7, 2020

/info

@ti-srebot
Copy link
Contributor

Before closing the bug, please complete the following info

Case Not a bug:

1. please remove 'type/bug' label
2. please add notes which operation is wrong

Case Duplicate bug:

1. add 'type/duplicate' label
2. add original bug link

Case Bug:

1. RCA
    Please write the reason why this issue occurs

2. Symptom
    What's customers will see when this bug occurred

3. Correct minimal reproduce step:(optional)

4. Solution(optional):
    upgrade or W/A(work around)
    If you choose W/A, please fill W/A steps in the next step

5. W/A:
    Please write the W/A

6. Affected versions
    [Since version: End version], can be multiple collections
    If the bug only affect unreleased version, please input: unreleased
    eg:  [v3.0.1:v3.1.5],[v4.0.1:v4.0.5] or unreleased

7. Fix versions
    Release versions that will include this fix.
    If the Fix version have not been planned when the issue is closed, please input: unplanned
    eg: v4.0.5, v3.0.1 or unplanned

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/P1 The issue has P1 priority. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
8 participants