我正在尝试此查询
select
employee_id
,first_name
,last_name
, case
salary when(( commission_pct > 0) AND (commission_pct <= 0.15))
then salary*20/100
when commission_pct > 0.15
then salary*25/100
else 0
end INCENTIVE_AMT
from employees
order by employee_id;
但它显示缺少关键字错误
我收到此错误&#34; commission_pct&gt; 0&#34;点。
请帮帮我
答案 0 :(得分:4)
别名出现在end
之后。
select case when this then that
else somethingelse end aliasName
你有这个:
select case when this then that aliasName
else something else aliasName end
答案 1 :(得分:0)
就语法而言,应可以:
gauss_2D
但是,没有多大意义 - 前两种情况几乎相同 - 请注意,你正在看
select employee_id,
first_name,
last_name,
case when commision_pct > 0 and commision_pct <= 0.15 then salary * 20 / 100
when commision_pct < 0.15 then salary * 25 / 100
else 0
end incentive_amt
from employees
order by employee_id;
when commision_pct <= 0.15
我说你必须改变它。
[编辑:关键字ain&t; t缺失]
我创建了一个虚拟 EMPLOYEES表,以便查询不会失败。然后我跑了 - 你可以看到,一切都很好。我建议你这样做 - 在你的SQL * Plus会话中发布when commision_pct < 0.15
和CREATE TABLE
,这样我们就可以看到你做了什么以及Oracle如何回应。
SELECT
答案 2 :(得分:0)
这是您的查询:
select
employee_id,
first_name,
last_name,
case
when COMMISSION_PCT > 0 AND COMMISSION_PCT <= 0.15
then salary*20/100
when commission_pct < 0.15
then salary*25/100
else 0
end INCENTIVE_AMT
from employees
order by employee_id;