在SQL中使用DECODE语句



我一直在尝试学习SQL,我正在学习DECODE语句:

这是我试图使用的查询:

SELECT DECODE(FIRST_NAME,'Steven','Name is Steven','Neena','Name is Neena','Some other name') AS "NAME" FROM hr.employees;

此查询工作成功,但当我尝试查询时:

SELECT DECODE(FIRST_NAME,'Steven','Name is Steven','Neena','Name is Neena','Some other name') AS "NAME" WHERE FIRST_NAME='Steven' FROM hr.employees;

此查询的输出为:

ORA-00923: FROM keyword not found where expected

有人能解释我怎么了吗?

Where子句需要放在From子句之后。

SELECT DECODE(FIRST_NAME,'Steven','Name is Steven','Neena','Name is Neena','Some other name') AS "NAME"  
FROM hr.employees
WHERE FIRST_NAME='Steven';

相关内容

  • 没有找到相关文章

最新更新