BrightHalo BrightHalo - 1 year ago 105
SQL Question

Oracle SQL Updating Salary and Column Aliasing in a Select Query

I am having problems implementing code to perform a couple calculations and setting column aliases.

Situation description:

The management wants to increase salary of all employees by 10%. Write a query to display empid, current salary, increased salary and incremented amount.

EmpId and Salary being existing columns in the table EmpDetails.

My Oracle SQL attempt:

Salary AS 'Current Salary',
Salary*1.10 AS 'New Salary',
Salary*1.10-Salary AS 'Incremented Amount'
FROM EmpDetails

The output from my attempt is nothing. The interpreter doesn't support error messages and has issues displaying seemly valid code when it is incorrect for the problem for seemly any reason. This has left me confused while learning Oracle SQL syntax so the problem is likely the syntax in my attempt.

Is there way valid way to do this as a verbose select query like I attempted or maybe a simpler way for someone newer to SQL that uses multiple Alter/Update/Select commands?

Answer Source

enclose the alias with double quote.

Salary AS "Current Salary",
Salary*1.10 AS "New Salary",
Salary*1.10-Salary AS "Incremented Amount"
FROM EmpDetails
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download