Arithmetic Operators in SQL:
Arithmetic operators are used to perform the certain arithmetic operators on numeric operands involved.
Below are the arithmetic operators. The + and - operands can also used as date arithmetic.
> Addition(+)
> Subtraction (-)
> Multiplication (*)
> Division ( / )
ADDITION ( + ) :
Addition operator is used to perform the addition on two numbers.
syntax: SELECT number + number from DUAL;
DUAL is a pre-defined virtual table which is having one row and one column. Dual table is used to test the pre-defined and user defined functions as well.
Example: SELECT 10+10 from DUAL;
Output : 20.
In the same way, We can use the column value based on the condition. Below is the example for the same.
Suppose assume, we have a table called "employee" and it have two columns(salary and bonus)
SQL> select salary + bonus from employee;
Same way we can use Plus operator to add the date. In below query SYSDATE means current date.
So it will return next date because we are using PLUS one.
SQL> select sysdate+1 from dual;
SUBTRACTION (-):-
Subtraction operator is used to perform the subtraction operation on two numbers. This is same like general subtraction operation.
Syntax: SELECT number - number from DUAL;
Example : SQL> select 100 - 90 from DUAL; Output: 10
MULTIPLICATION( * ):
Multiplication operator is used to perform Multiply operation on two numbers.
Synatx: SELECT number*number from DUAL:
Example : SQL> Select 10*10 from DUAL: Output: 100
DIVISION ( / ) :
Division operator used to perform the division operation on two numbers.
Synatx : SELECT number/number from DUAL;
Example : SQL> Select 100/10 from DUAL; Output: 10
Refer the below link for Basic introduction of SQL commands(Create, Insert and select ..etc.).
If you have any doubts, Please drop a comment.
Thank You
Comments
Post a Comment