OCP-047 group by rollup and where clause

225. View the Exhibit and examine the descriptions of ORDER_ITEMS and ORDERS
tables.You want to display the CUSTOMER_ID, PRODUCT_ID, and total
(UNIT_PRICE multiplied by QUANTITY) for the order placed. You also want to
display the subtotals for a CUSTOMER_ID as well as for a PRODUCT_ID for the
last six months.Which SQL statement would you execute to get the desired
output?
A. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total" FROM order_items oi JOIN orders o ON oi.order_id=o.order_id
GROUP BY ROLLUP (o.customer_id,oi.product_id)
WHERE MONTHS_BETWEEN(order_date, SYSDATE) <= 6;
B. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total"FROM order_items oi JOIN orders o ON oi.order_id=o.order_id
GROUP BY ROLLUP (o.customer_id,oi.product_id)
HAVING MONTHS_BETWEEN(order_date, SYSDATE) <= 6;
C. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total"FROM order_items oi JOIN orders o
ON oi.order_id=o.order_id GROUP BY ROLLUP (o.customer_id, oi.product_id)
WHERE MONTHS_BETWEEN(order_date, SYSDATE) >= 6;
D. SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity)
"Total"FROM order_items oi JOIN orders o ON oi.order_id=o.order_id
WHERE MONTHS_BETWEEN(order_date, SYSDATE) <= 6
GROUP BY ROLLUP (o.customer_id, oi.product_id) ;
Answer: D


题目解释:  WHERE需在Group by前面





正解:




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值