Having a problem with an SQL query.
Query is as follows:
SELECT employee_id,
last_name,
first_name,
TO_DATE('31-DEC-01') - hire_date as "days_with_company",
salary*12 as "annual_salary",
(CASE WHEN "days_with_company" < 720 THEN "annual_salary"*0.1
WHEN "days_with_company" >= 720 AND "days_with_company" < 1440 THEN "annual_salary"*0.2
ELSE "annual_salary"*0.3 END) as "bonus",
("annual_salary" + "bonus") as "total_compensation"
FROM employees;
But I get the following error:
ORA-00904: "bonus": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 9 Column: 28
When I look up the error it doesn't appear I'm doing anything wrong!
Please advise.