我需要在case语句中计算SQL Oracle中不同字段的一些值
var x = document.getElementById("bezeichnung");
var btn = document.createElement("BUTTON"); // Create a <button> element
btn.innerText = x.value; // Append the text to <button>
document.body.appendChild(btn);
查询无法在第二种情况声明中识别字段'AmountCalc。
有什么想法吗?
答案 0 :(得分:1)
将select语句中的case语句替换为
case (case field03
when 'calc1' then field01 - field02
when 'calc2' then field01 + field02
end) when 0 then 'amount is 0'
else 'Greater than 0'
end as result
答案 1 :(得分:0)
您可以使用嵌套查询实现此目的:
select field01
, field02
, AmountCalc
, case AmountCalc
when 0 then 'amount is 0'
else 'Greater than 0'
end as result
from
( select field01
, field02
, case field03
when 'calc1' then field01 - field02
when 'calc2' then field01 + field02
end as AmountCalc
from myTable
)