A derived column is a result of a calculation (most of the time mathematical) that happens during the SQL query processing and generates a new column which is not part of the original table definition. For example, in our table we have salary column present but when we want to extract a percentage of the salary or portion of the salary, we generally create a column on the fly with the mathematical calculation from the existing salary column.

Suppose in a well managed successful organization, the HR head decided to reduce the salary by 20% of all the employees just to show that he is something. To know the future salary of the employees working in the dept 114, we have to use a derived column as mentioned in the following query.

SELECT emp_no, dept_no, salary “Actual Salary”,
(Salary * 80/100) “Proposed Salary” <== This is a derived Column
FROM emp
WHERE dept_no = 114
GROUP BY 1,2,3,4
ORDER BY 1, 2

Result:-

emp_no

dept_no Actual Salary Proposed Salary
1,100 114 46,000 36,800
5,000 114 65,000 52,000
7,000 114 62,000 49,600

Our Random Articles

More Links