August 14th, 2008

Arithmetic Operations, Part 1 of 2

Posted by admin in C. SELECT Statement

An operator acts on one or more elements. Arithmetic operators give a mathematical result.

-expression                Reverses the sign of an expression.
+expression                Leaves the expression unchanged.
expression1 + expression2  Adds expression1 and expression2.
expression1 - expression2  Subtracts expression2 from expression1.
expression1 * expression2  Multiplies expression1 and expression2.
expression1 / expression2  Divides expression1 by expression2.

Operators with higher precedence are evaluated first. Arithmetic operators (+, -, *, /, etc.) are evaluated before comparison operators (<, =, >, etc.), which are evaluated before logical operators (AND, OR, NOT). You may have to use parentheses to control the calculation order. You may recall having learned the mathematical order of operations.

A * B < C OR D

is the same as

((A * B) < C) OR D 

A function is a named routine that performs a task on an argument passed to it in parentheses.

While these are the arithmetic operators required by the SQL standards, RDBMS implementations by various providers include many functions and operators beyond these basic functions for scientific, trigonometric, financial, statistical, mathematical, concatenation, string, conversion, system, date/time, bit manipulation, security, and other functions.

Comments are closed.

Sorry, the comment form is closed at this time.