10. View the Exhibit and examine the structure of the PROMOTIONS table.
Each promotion has a duration of at least seven days .
Your manager has asked you to generate a report, which provides the weekly cost for each promotion
done to l date.
Which query would achieve the required result?
A. SELECT promo_name, promo_cost/promo_end_date-promo_begin_date/7
FROM promotions;
B. SELECT promo_name,(promo_cost/promo_end_date-promo_begin_date)/7
FROM promotions;
C. SELECT promo_name, promo_cost/(promo_end_date-promo_begin_date/7)
FROM promotions;
D. SELECT promo_name, promo_cost/((promo_end_date-promo_begin_date)/7)
FROM promotions;
Answer: D
题目解析:
题目的意思:是求每个促销在促销期间内,每周的的平均消费。
由给出的表可知:促销的总花费为 promo_cost 促销的时长为 (promo_end_date-promo_begin_date),把促销时长转换为周需要除7为
(promo_end_date-promo_begin_date)/7,所以每周的平均花费为promo_cost/( (promo_end_date-promo_begin_date)/7)
显然D是正确的,这题主要考察表达式的运算顺序,答案ABC在执行的时候都会提示语法错误。