当我尝试在以下情况下运行我的情况时,在from子句中出现错误'语法错误:
select ewc_code, shortclass as EWCDesc, tonnage as tonnes,
waste_fate as fate, 'deposit wpa' as destination
from hwi
CASE waste_fate
WHEN 'Transfer (r)' THEN 'Transfer'
When 'Transfer (d)' then 'transfer'
else waste_fate
答案 0 :(得分:1)
首先,CASE
应位于您的查询中,最有可能位于SELECT
子句中。
其次,您错过了END
声明中的CASE
:
SELECT ewc_code, shortclass as EWCDesc, tonnage as tonnes, waste_fate as fate,
'deposit wpa' as destination,
CASE waste_fate
WHEN 'Transfer (r)' THEN 'Transfer'
WHEN 'Transfer (d)' THEN 'transfer'
ELSE waste_fate
END
FROM hwi
答案 1 :(得分:0)
您错过了END
:
CASE WHEN waste_fate = 'Transfer (r)' THEN 'Transfer'
WHEN waste_fate = 'Transfer (d)' THEN 'transfer'
ELSE waste_fate END
这会返回一个标量,你需要考虑你想做什么。
最有可能的是,您希望将其添加到SELECT
子句而不是FROM
子句中。