ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Read Accesses → SELECT → SELECT - result → SELECT - select_list → SELECT - col_spec → SELECT - sql_exp

# sql_exp - sql_arith

Other versions:
| *7.31***7.40** | 7.54

## Syntax

```
... [-] operand1 +|-|
```*|/ [-]operand2 [+|-|*|/ [-] operand3 ... ] ...

### Effect

Arithmetic expression in Open SQL. The operators perform arithmetic calculation between two adjacent operands. The possible operators are:

`+`

for adding the operands

`-`

for subtracting the right operand from the left operand

`*`

for multiplying the operands

`/`

for dividing the left operand by the right operand

The operators * and / have a higher priority than the operators + and -. Within a
parenthesis level, operations with a higher priority
are performed before those with a lower priority. Operations with identical priorities are performed
from left to right. A minus sign - can be placed in front of an operand that
does not directly follow an operator +, -, *, or

`/`

.The arithmetic expressions in Open SQL are distinguished as follows, depending on the data type of the operands:

- Integer Expressions

`b`

, `s`

,
and `i`

plus packed numbers of the types DEC, CURR, and QUAN or`p`

without decimal places. The operator `/`

is not allowed in integer expressions. An overflow occurs and an exception of the class CX_SY_OPEN_SQL_DB is raised when
- the value range of the type INT4 or
`i`

is exceeded in operations between two integer numbers.

- the value range of a packed number with length 31 without decimal places is exceeded in operations using packed numbers.

- Decimal Expressions

`p`

with decimal places. The operator `/`

is not allowed in decimal expressions. The result has the type DEC with the length 31 and a maximum of 14 decimal places. Using the associated
assignment rule, it can be assigned to all
numeric ABAP types whose value range is large enough, except for decimal floating point numbers.
- Floating Point Expressions

`/`

.
If an operation exceeds the value range of the type FLTP or division by 0 takes place, an overflow occurs
and an exception of the class CX_SY_OPEN_SQL_DB is raised. The result has the type FLTP and can only be assigned to a field with the ABAP type `f`

in accordance with the associated
assignment rule.
No other combinations of operand are allowed. The operands can be appropriate columns, host variables, literals or any expressions constructed from these three elements.

If the operand of an arithmetic expression has the null value, the result of the full arithmetic expression is the null value.

Notes

- The arithmetic expressions have been divided into the three categories integer expression, decimal expressions, and floating point expression to achieve the same behavior in all supported database systems.

- Operators that do not have the type FLTP can be transformed to an operator with the type FLTP using
a
`CAST`

expression and hence used in floating point expressions.

- Decimal floating point numbers are not supported in
`SELECT`

expressions and are not valid operands here.

- A plus sign
`+`

cannot be specified in front of an operand of an arithmetic expression. If a minus sign`-`

is specified after an operator`+`

,`-`

,`*`

, or`/`

, the sign and the operand must be placed in parentheses.

- If an operand is prefixed with a minus sign (
`-`

), the syntax check is performed in a strict mode, which handles the statement more strictly than the regular syntax check.

Example