我想根據任期顯示名字、薪水、任期和獎金,但我收到此錯誤:
“TENURE”:無效的識別符號
這是我的查詢:
select
first_name as "First Name", Salary,
round((sysdate - to_date(hire_date))/365.25,2) as Tenure,
Salary*(
CASE
when Tenure between 0 and 10 then 0.05
when Tenure between 11 and 15 then 0.1
when Tenure between 16 and 20 then 0.15
when Tenure > 20 then 0.2
END) as Bonus
from employees;
uj5u.com熱心網友回復:
嘗試這個。
SELECT AA.first_name as "First Name", AA.Salary,
AA.Salary*(
CASE
when AA.Tenure between 0 and 10 then 0.05
when AA.Tenure between 11 and 15 then 0.1
when AA.Tenure between 16 and 20 then 0.15
when AA.Tenure > 20 then 0.2
END) as Bonus
FROM (select
first_name, Salary,
round((sysdate - to_date(hire_date))/365.25,2) as Tenure
from employees)) AA;
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/496291.html
標籤:mysql
