August 15th, 2008

Arithmetic Operations, Part 2 of 2

Posted by admin in C. SELECT Statement

Column names can be intermixed with arithmetic symbols to produce an arithmetic result.

SELECT column1 arithoper1 column2,
       column3 arithoper2 column4, ...
  FROM table1, table2, ...;

> Valid expression symbols are: + (addition), – (subtraction), * (multiplication), / (division).
> If any operand contains the NULL value, the entire calculation evaluates as NULL.
> The columns and operands used within the expression must be compatible data types.
> If operands are mixed numeric data-types, the ANSI/ISO standard specifies automatic data-type conversion from integers to decimal numbers, and from decimal numbers to floating point numbers as required. You can mix these data types in a numeric expression.
> DB2 also uses the || symbol to concatenate, or combine two fields into one.

Comments are closed.

Sorry, the comment form is closed at this time.