Arithmetic Operators

SAP ASE uses certain arithmetic operators.

Operator

Meaning

+

Addition

Subtraction

*

Multiplication

/

Division

%

Modulo (Transact-SQL extension)

Operators have certain precedence levels among arithmetic operators. In order of precedence (from lowest to highest):
  1. unary (single argument) - + ~
  2. * /%
  3. binary (two argument) + - & | ^
  4. not
  5. and
  6. or

Use addition, subtraction, division, and multiplication on exact numeric, approximate numeric, and money type columns.

A modulo operator, which can be used on exact numeric columns except money and numeric, finds the remainder after a division involving two numbers. For example, using integers: 21 % 11 = 10 because 21 divided by 11 equals 1, with a remainder of 10. You can obtain a noninteger result with numeric or decimal datatypes: 1.2 % 0.07 = 0.01 because 1.2 / 0.07 = 17 * 0.07 + 0.01. You receive similar results from float and real datatype calculations: 1.2e0 % 0.07 = 0.010000.

When you perform arithmetic operations on mixed datatypes (for example, float and int) SAP ASE follows specific rules for determining the type of the result.

Related concepts
Datatypes