Performing Arithmetic Operations
A monadic arithmetic operator performs a mathematical operation on a single numeric operand to produce a result. The - (negation) operator changes the sign of its operand, and the not very useful + (identity) operator leaves its operand unchanged. A dyadic arithmetic operator performs a mathematical operation on two numeric operands to produce a result. These operators include the usual ones: + (addition), - (subtraction), * (multiplication), and / (division). Table 5.1 lists SQL’s arithmetic operators (expr is a numeric expression).
To change the sign of a number:
- Type - expr expr is a numeric expression (Listing 5.4 and Figure 5.4).
To add, subtract, multiply, or divide:
- Type expr1 + expr2 to add, expr1 ...
Get SQL: Visual QuickStart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.