我一直在尝试学习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';