我想要一个仅根据条件显示好或坏的列:
select (if (salary>10000) then 'good' else 'bad')as "Grade" from employees;
它给了我
ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Error at Line: 14 Column: 19
错误出现在“>”处。我该怎么写呢?
最佳答案
您可以(应该?)使用 ANSI-SQL case
表达式:
SELECT CASE WHEN salary > 10000 THEN 'good' ELSE 'bad' END AS "Grade"
FROM employees;
关于sql - Oracle sql中的if语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47821623/