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

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


         
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值