- Arithmetic operations can be used on the data which type is ‘date’ or ‘number’.
- The priority of the operators is like below ;
USAGE OF THE ARITMETHIC OPERATORS
- Let’s list the name, surname, salary and the new salary which is increased by 5% ; and give alias to them.
SELECT first_name NAME, last_name SURNAME , salary SALARY,(salary+salary*8/100)as NEW_SALARY FROM hr.employees;
THE NULL VALUE
- Null is a value that is unknown, unspecified or inconvenient.
- Null value is not zero(0) or whitespace. It is a common mistake.
- If a null value joins an arithmetic operation the result will be null.
- Let’s list the name, surname, salary, and commission if it exist, with the aliases.
SELECT first_name NAME, last_name SURNAME , salary SALARY, (salary*commission_pct)as COMMISSION FROM hr.employees;
THE CONCATENATION OPERATOR
- It combines columns or character sets with other columns.
- It is represented as double pipe : ||
- It creates a columns which is character type.
- Also , CONCAT command can used to concetanation.
- Let’s list the name, surname and salary with concatenation.
SELECT first_name||’ ‘||last_name AS “NAME SURNAME “,concat(‘Salary : ‘,salary) “SALARY” FROM hr.employees;
- The DISTINCT command is used to list the repeating rows just one time.
- Let’s list all departments of the company.
SELECT DISTINCT department_name FROM hr.departments;
VIEWING THE STRUCTURE OF TABLE
- The DESCRIBE command is used to view the table structure.
- DESC[RIBE] table_name;
- Let’s list the structure of the hr.employees table.
You can continue to read from this link ;
1,535 views last month, 2 views today
loved the site. “*” and “/” operators have equal precedence; and below them are “+” and “-” operators having equal precedence.