您的位置:首页 > 其它

17.View the Exhibit and examine the data in the EMPLOYEES table.

2016-01-20 16:29 435 查看
17.View the Exhibit and examine the data in the EMPLOYEES table.



You want to generate a report showing the total compensation paid to each employee to date.

You issue the following query

SQL>SELECT ename ' joined on ' hiredate', the total compensation paid is '

TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)

"COMPENSATION UNTIL DATE"

FROM employees;

What is the outcome?

A:It generates an error because the alias is not valid.

B:It executes successfully and gives the correct output.

C:It executes successfully but does not give the correct output.

D:It generates an error because the usage of the ROUND function in the expression is not valid.

E:It generates an error because the concatenation operator can be used to combine only two items.

答案:C

解析:这道题考察的还是列的别名

A:错误,"COMPENSATION UNTIL DATE" 只要双引号括起来,空格是可以使用的

B:错误,这里说给了一个正确的输出,题目问的是显示每个雇员支付的薪酬总额,咱们先不说sal这个字段代表的是月薪、年薪还是日薪什么的,咱不管它,按照给的sql语句应该是年薪

这里的问题主要是没有处理值为null的情况,从图中可以看出smith的comm为null,那他的工资+comm最后结果也为null,

对null进行算数运算,结果为null

SQL> select 1+null a,1*null b,1/null c,'1'||null d from dual;

A          B          C D
---------- ---------- ---------- -
1

1 row selected.
C:正确

D:错误,说是round不合法,这里是可以使用的round的参数有两种,一种是number,一种是date,这里两个日期相减最后是相差的天数是number,最后除以365也是number类型,因此可以使用

E:错误,这里说的是级联操作只能最多2个,这里说的级联操作应该指的是||这个东西,这里都没有使用||使用的是空格,我测试空格是不可以的,比如下面的示例,这里暂且不管

SQL> select a b from table1;

B
----------
1
2
SQL> select a 'w' b from table1;
select a 'w' b from table1
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: