You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Sql select query get "Division by zero" error #23404
kind/bugSomething isn't workingkind/compatibilityThe compatibility with mysql 8.0 should be discussed further.priority/p0Critical feature that should be implemented in this version
CREATE TABLE test_div_zero (
a INT,
b INT
);
INSERT INTO test_div_zero (a, b) VALUES
(100, 0),
(200, 0),
(300, 0);
SELECT
SUM(a) AS sum_a,
SUM(b) AS sum_b,
SUM(a)/SUM(b) AS raw_ratio, -- 原始写法,得 NULL
COALESCE(SUM(a) / NULLIF(SUM(b),0), 0) AS safe_ratio -- 安全写法,得 0
FROM test_div_zero;
kind/bugSomething isn't workingkind/compatibilityThe compatibility with mysql 8.0 should be discussed further.priority/p0Critical feature that should be implemented in this version
Activity
XuPeng-SH commentedon Jan 7, 2026
@heni02 fixed