Use arithmetic operators to perform arithmetic calculations on data in SELECT queries. The following outlines the arithmetic operators supported by the SQL engine.
Operator |
Description |
|---|---|
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
Calculations can be performed wherever non-aggregated data values are allowed, such as in a SELECT or WHERE clause. In following example, a field value is multiplied by a numeric literal:
SELECT (GrossAmount * 0.0825) AS Tax FROM INHEAD
Arithmetic calculations are performed in the normal order of precedence: multiplication, division, addition, and then subtraction. To cause a calculation to be performed out of the normal order of precedence, use parentheses around the operation to be performed first. Here the addition is performed before the multiplication:
SELECT (UOMSellingPrice * (UOMQuantitySupplied + 1)) As Result FROM INLINE
Arithmetic operators operate only on numeric and date/time values. The following example shows how you would add 30 days to a date to get an Invoice due date for an Invoice in a SELECT SQL statement:
SELECT DocumentDate, (DocumentDate + 30) AS DueDate, GrossAmount FROM INHEAD WHERE DocumentDate BETWEEN '2025-1-01' AND '2025-01-31'