Databases Reference
In-Depth Information
Expressions
To finish off our analysis of the SELECT syntax, let's look at the expression part
of the SELECT statement. Let's say we would like to see how salaries would look
if everyone got a 15 percent pay increase. All of the information we need to see
is still in one table, the EMP table, but we need to perform some kind of calcula-
tion on one of the existing fields. To calculate a 15 percent pay increase, we need
to not only see the existing salary but also multiply the SAL column by 1.15:
select empno, ename, sal, sal*1.15 from emp;
EMPNO ENAME SAL SAL*1.15
---------- ---------- ---------- ----------
7369 SMITH 800 920
7499 ALLEN 1600 1840
7521 WARD 1250 1437.5
7566 JONES 2975 3421.25
7654 MARTIN 1250 1437.5
7698 BLAKE 2850 3277.5
7782 CLARK 2450 2817.5
7788 SCOTT 3000 3450
7839 KING 5000 5750
7844 TURNER 1500 1725
7876 ADAMS 1100 1265
7900 JAMES 950 1092.5
7902 FORD 3000 3450
7934 MILLER 1300 1495
14 rows selected.
To make the proposed salary column more readable, we could use either
a column alias or iSQL*Plus column-formatting commands. We might also
want to show a total for the SAL and SAL*1.15 columns or show each salary
increase to exactly two decimal places. Some of these more advanced format-
ting techniques will be covered in Chapter 9, “Reporting Techniques.”
Search WWH ::




Custom Search