Applying Arithmetical Operations In Select Statements :
1. Arithmetic expressions can be implemented through SELECT statement.
2. Arithmetic expressions can be implemented to
- Modify the way the data is displayed.
- Perform calculations.
- Implement WHAT - IF scenarios.
- Simple column names
- Constant numeric values
- Arithmetic operators.
Arithmetic Operators :
1. The arithmetic operators can be used to created expressions on NUMBER and DATE data.
2. The arithmetic operators supported are
- Addition +
- Subtraction -
- Multiply *
- Divide /
4. SQL * Plus ignores back spaces before and after the arithmetic operator.
SQL> SELECT Empno, Ename, Sal, Sal+500 from Emp ;
Operator Precedence :
- Multiplication and division take priority over addition and subtractions (* ,/, +, -).
- Operators of the same prority and evaluated from left to right.
- To prioritize evaluation and to increase clarity parenthesis can be implemented.
SQL> SELECT Empno,Ename,Sal, 12*sal+100 FROM Emp;Note : According to operator precedence, the evaluation of an expression can be changed.
SQL> SELECT Empno,Ename,Sal, (12*sal)+100 FROM Emp;
SQL> SELECT Empno,Ename,Sal, 12*(sal+100) FROM Emp;



0 comments
Post a Comment
Do comment to make this blog better