OCP-1Z0-051 第118题 GROUP BY,HAVING子句
2014-05-13 08:49
399 查看
一、原题
View the Exhibit and examine the structure of the PROMOTIONS table.
Examine the following two SQL statements:
Statement 1
SQL>SELECT promo_category,SUM(promo_cost)
FROM promotions
WHERE promo_end_date-promo_begin_date > 30
GROUP BY promo_category;
Statement 2
SQL>SELECT promo_category,sum(promo_cost)
FROM promotions
GROUP BY promo_category
HAVING MIN(promo_end_date-promo_begin_date)>30;
Which statement is true regarding the above two SQL statements?
A. statement 1 gives an error, statement 2 executes successfully
B. statement 2 gives an error, statement 1 executes successfully
C. statement 1 and statement 2 execute successfully and give the same output
D. statement 1 and statement 2 execute successfully and give a different output
答案:D
二、题目翻译
查看PROMOTIONS表的结构
评估下面的2个语句
关于上面两个SQL语句,哪句话是正确的?
A.语句1报错,语句2执行成功。
B.语句2报错,语句1执行成功。
C.都执行成功,并给出相同结果。
D.都执行成功,但给出不同的结果。
三、题目解析
WHERE是分组之前筛选数据,HAVING是分组之后筛选数据,所以结果是不一样的。
View the Exhibit and examine the structure of the PROMOTIONS table.
Examine the following two SQL statements:
Statement 1
SQL>SELECT promo_category,SUM(promo_cost)
FROM promotions
WHERE promo_end_date-promo_begin_date > 30
GROUP BY promo_category;
Statement 2
SQL>SELECT promo_category,sum(promo_cost)
FROM promotions
GROUP BY promo_category
HAVING MIN(promo_end_date-promo_begin_date)>30;
Which statement is true regarding the above two SQL statements?
A. statement 1 gives an error, statement 2 executes successfully
B. statement 2 gives an error, statement 1 executes successfully
C. statement 1 and statement 2 execute successfully and give the same output
D. statement 1 and statement 2 execute successfully and give a different output
答案:D
二、题目翻译
查看PROMOTIONS表的结构
评估下面的2个语句
关于上面两个SQL语句,哪句话是正确的?
A.语句1报错,语句2执行成功。
B.语句2报错,语句1执行成功。
C.都执行成功,并给出相同结果。
D.都执行成功,但给出不同的结果。
三、题目解析
WHERE是分组之前筛选数据,HAVING是分组之后筛选数据,所以结果是不一样的。
相关文章推荐
- OCP-1Z0-051 第119题 GROUP BY,HAVING子句的顺序
- OCP-1Z0-051 第115题 HAVING,GROUP BY子句的应用
- OCP-1Z0-051 第116题 GROUP BY,HAVING子句应用
- OCP-1Z0-051 第114题 HAVING,GROUP BY子句的应用
- OCP-1Z0-051 第111题 GROUP BY子句
- OCP-1Z0-051 第117题 WHERE和HAVING子句的区别
- OCP-1Z0-051 第161题 insert子句中的子查询
- OCP-1Z0-051 第140题 子查询中使用GROUP BY注意事项
- OCP-1Z0-051 第112题 GROUP BY,ORDER BY子句
- OCP-1Z0-051 第122题 NATURAL JOIN(自然连接)和USING子句的用法
- [每日一题] OCP1z0-047 :2013-07-22 group by 子句........................................................11
- [每日一题] OCP1z0-047 :2013-07-22 group by 子句........................................................11
- OCP-1Z0-051 补充题库 第7题 ORDER BY 子句
- OCP-1Z0-051 第113题 GROUP BY, TO_CHAR的应用
- OCP-1Z0-051 第123题 JOIN中的USING子句,ON子句
- [每日一题] OCP1z0-047 :2013-07-22 group by 子句
- OCP-1Z0-051 第156题 集合操作中的ORDER BY 子句
- OCP-1Z0-051 第7题 ON和USING子句的用法与区别
- OCP-1Z0-051-2015-17题
- OCP-1Z0-051-2015-31题