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
D:错误,说是round不合法,这里是可以使用的round的参数有两种,一种是number,一种是date,这里两个日期相减最后是相差的天数是number,最后除以365也是number类型,因此可以使用
E:错误,这里说的是级联操作只能最多2个,这里说的级联操作应该指的是||这个东西,这里都没有使用||使用的是空格,我测试空格是不可以的,比如下面的示例,这里暂且不管
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
相关文章推荐
- odps编写UDF的实现
- js 打印指定页面部分打印
- Jenkins+Maven+Git搭建持续集成和自动化部署的配置手记
- 按钮事件响应的注意点
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- 数据库事务的隔离级别
- 仿淘宝详情页上拉看详情
- easyui控件与Activex控件遮挡问题
- .NET的三种缓存(页面缓存,控件缓存,自定义缓存)
- C# 对象与JSON串互相转换
- css之clearfix清除浮动
- spark idea 源码阅读环境搭建
- How to Create an OCM Response file to Apply a Patch (文档 ID 966023.1)
- iOS 【原生API NSURLConnection 网络请求】
- Android之ExpandableListView的属性(Group不展开)
- Fiddler抓包和App重置密码漏洞
- Android自定义控件:Android L控件点击水波纹的实现(源码 + Demo)
- 各种模板
- ReactJS组件间沟通的一些方法
- ServiceStack.OrmLite 笔记9 -code first 必须的代码优先