All Products
Search
Document Center

AnalyticDB:Arithmetic operators

Last Updated:Mar 28, 2026

AnalyticDB for MySQL supports the following arithmetic operators for numeric calculations on constants and columns.

OperatorSyntaxDescription
+a + bAddition
-a - bSubtraction
*a * bMultiplication
/a / bDivision
DIVa DIV bInteger division — divides a by b and returns a truncated integer
% or MODa % b or a MOD bModulo — returns the remainder of a divided by b
- (unary)-aNegation — changes the sign of a

+

Adds two numeric expressions.

SELECT 3 + 5;       -- 8
SELECT 3 + 2.9875;  -- 5.9875

-

Subtracts one numeric expression from another.

SELECT 3 - 5;    -- -2
SELECT 3 - 1.5;  -- 1.5

*

Multiplies two numeric expressions.

SELECT 3 * pi();  -- 9.42477796076938

/

Divides one numeric expression by another.

SELECT 3 / pi();  -- 0.954929658551372

DIV

Divides one integer expression by another and returns a truncated integer result.

SELECT 3 DIV pi();  -- 0
SELECT 33 DIV 2;    -- 16

% or MOD

Returns the remainder of one numeric expression divided by another. % and MOD are equivalent.

SELECT 3 MOD pi();  -- 3.0
SELECT 33 % 2;      -- 1

- (unary)

Changes the sign of a numeric expression — converts a positive number to negative, or a negative number to positive.

SELECT -2;   -- -2
SELECT --2;  -- 2