- arithmetic expressions
- aliases (alternative names) columns
- Concatenation
- literals
Arithmetic expressions
The arithmetic expression may be the column names, numeric constants and arithmetic operators:
addition
- subtraction
* multiplication
/ sharing
example
SELECT ENAME, SAL FROM EMP * 12;
The expression is retained following priority actions:
- multiplication
- sharing
- adding
- subtraction
For example, in an arithmetic expression 250+12*34 is first calculated value of the expression 12*24 and the result is added value of the 250. Sequence of actions can be changed by using parentheses. For example, in an arithmetic expression (250+12)*34 first expression value is calculated 250+12, and the result is multiplied by the 34
Column Aliases
The default column headers can be replaced by other names, which are more significant.
Alias is administered directly after the name of the column whose name we want to change. Spaces in the alias is not allowed, but you can create an alias with a space having a whole in double quotes.
example
SELECT ENAME Name , SAL*12 Salary, COMM Commision
FROM EMP;
Concatenation operator
Concatenation operator (||) allows you to combine a column with a column, literal, an arithmetic expression or a constant value. The arguments are combined to form one result column.
To connect the columns empno and ENAME and label them by way of EMPLOYEE, we write:
SELECT EMPNO|| ENAME EMPLOYEE
FROM EMP;
Literals
In addition to the columns in the SELECT list may contain literals (strings or numbers). Then for each line to be printed the same literal value:
EMPLOYEE SELECT ENAME, 'work in department', DEPTNO DEPARTMENT
FROM EMP;
No comments:
Post a Comment