select语句oracle

时间:2014-11-30 04:46:00

标签: sql oracle

我从oracle sql基础知识书中学习oracle sql,我发现了这个测验,答案正如Oracle所说2,3但是他们不能在sql开发人员身上工作

我知道他们必须像这样

  

SELECT first_name,last_name,job_id,salary * 12" annual_sal"来自员工;

     

SELECT first_name,last_name,job_id,salary AS" annual_sal"来自员工;

但Oracle给出了答案,如下图所示......

enter image description here

1 个答案:

答案 0 :(得分:2)

这些答案都不正确。如果别名由"分隔,则嵌入空格仅作为列别名有效。此外,+不能用于连接(我假设是)字符串 - 而是可以使用||。它们可以更正为:

1

SELECT first_name, last_name, job_id, salary*12 AS "Yearly Sal" FROM employees;

2

SELECT first_name, last_name, job_id, salary*12 "yearly sal" FROM employees;

3

SELECT first_name, last_name, job_id, salary AS "yearly sal" FROM employees;

4

SELECT first_name || last_name AS name, job_Id, salary*12 "yearly sal" FROM employees;