Read this Oracle Tutorial Point article to know about arithmetic operations in SQL and how to apply in SELECT statement. The Arithmetic operators will be used to create expressions on NUMBER and DATE data. The Arithmetic Operators supported are,
Applying Arithmetic Operations in SELECT Statement:
By using SELECT statements, Arithmetic Expressions can be implemented. Arithmetic Expressions can be implemented to,
Operator Precedence:
Multiplication(*) and Division(/) take preference over addition(+) and subtraction(-). Operators of the same priority are evaluated from left to right. To increase clarity and to prioritize evaluation parentheses can be implemented.
Based on the above SQL queries you try for other Arithmetic operators.
- Addition(+)
- Subtraction(-)
- Multiply(*)
- Divide(/)
Applying Arithmetic Operations in SELECT Statement:
By using SELECT statements, Arithmetic Expressions can be implemented. Arithmetic Expressions can be implemented to,
- Perform Calculations.
- Modify the way the data is displayed.
- Implement WHAT-IF Scenario.
- Simple Column names.
- Arithmetic operators.
- Constant numeric values.
SQL> SELECT ENO,ENAME,SAL,SAL+100 FROM EMP; SQL> SELECT ENO,ENAME,SAL,SAL-500 FROM EMP;
Operator Precedence:
Multiplication(*) and Division(/) take preference over addition(+) and subtraction(-). Operators of the same priority are evaluated from left to right. To increase clarity and to prioritize evaluation parentheses can be implemented.
SQL> SELECT ENO,ENAME,SAL,12 * SAL + 100 FROM EMP; SQL> SELECT ENO,ENAME,SAL,(12*SAL)+100 FROM EMP; SQL> SELECT ENO,ENAME,SAL,12*(SAL+100) FROM EMP;
Based on the above SQL queries you try for other Arithmetic operators.
Comments
Post a Comment