Help Center/ Data Warehouse Service/ Tool Guide/ DSC/ MySQL Syntax Migrating/ Data Manipulation Language (DML)/ Division Expressions
Updated on 2025-04-10 GMT+08:00
Division Expressions
In MySQL, in a division expression, if the divisor is 0, null is returned. GaussDB(DWS) reports an error. Therefore, the division expression is converted by adding an if condition expression.
Input
1 2 | select sum(c1) / c2 as result from table_t1; select sum(c1) / count (c3/c4) as result from table_t1; |
Output
1 2 | SELECT (if (c2 = 0, null, sum(c1) / c2)) AS "result" FROM table_t1; SELECT (if (count(if (c4 = 0, null, c3 / c4)) = 0, null, sum(c1) / count(if (c4 = 0, null, c3 / c4)))) AS "result" FROM table_t1; |
Parent topic: Data Manipulation Language (DML)
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.