一、原题
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是分组之后筛选数据,所以结果是不一样的。