047 第141题 请教

xianyi_ 2011-10-03 10:09:10
141. View the Exhibit and examine the descriptions for ORDERS and ORDER_ITEMS tables.
Evaluate the following SQL statement:
SELECT o.customer_id, oi.product_id, SUM(oi.unit_price*oi.quantity) "Order Amount"
FROM order_items oi JOIN orders o
ON oi.order_id = o.order_id
GROUP BY CUBE (o.customer_id, oi.product_id);
Which three statements are true regarding the output of this SQL statement? (Choose three.)
A. It would return the subtotals for the Order Amount of every CUSTOMER_ID.
B. It would return the subtotals for the Order Amount for every PRODUCT_ID.
C. It would return the subtotals for the Order Amount of every PRODUCT_ID and CUSTOMER_ID as one
group.
D. It would return the subtotals for the Order Amount of every CUSTOMER_ID and PRODUCT_ID as one
group.
E. It would return only the grand total for the Order Amount of every CUSTOMER_ID and PRODUCT_ID
as one group.
Answer: ABD

c和d感觉是一样的啊,还是我理解有误。。。
...全文
3880 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
善若止水 2014-06-19
  • 打赏
  • 举报
回复
还是按照cube里面的字段顺序比较好
tumblewind 2013-09-25
  • 打赏
  • 举报
回复
这是ORACLE官方教材上的一个例子,你可以看看,CUBE的用法: SELECT division_id, job_id, SUM(salary) FROM employees2 GROUP BY CUBE(division_id, job_id) ORDER BY division_id, job_id; DIV JOB SUM(SALARY) --- --- ----------- BUS MGR 530000 BUS PRE 800000 BUS WOR 280000 BUS 1610000 OPE ENG 245000 OPE MGR 805000 OPE WOR 270000 OPE 1320000 SAL MGR 4446000 SAL WOR 490000 SAL 4936000 SUP MGR 465000 SUP TEC 115000 SUP WOR 435000 SUP 1015000 ENG 245000 MGR 6246000 PRE 800000 TEC 115000 WOR 1475000 8881000
wizabone 2012-11-10
  • 打赏
  • 举报
回复
join是左边的在前面,两边全有才输出,当然选D left join 是以左边的为准,左边全部输出,右边没有为空 right join 是以右边为准,右边全部输出,左边没有为空
rendelei 2012-11-01
  • 打赏
  • 举报
回复
很显然不一样啊,先后的排序不一样,先按哪个分组就不一样。
ghost0614 2011-10-22
  • 打赏
  • 举报
回复
C. It would return the subtotals for the Order Amount of every PRODUCT_ID and CUSTOMER_ID as onegroup.
D. It would return the subtotals for the Order Amount of every CUSTOMER_ID and PRODUCT_ID as one group.
GROUP BY CUBE (o.customer_id, oi.product_id);
ngx20080110 2011-10-04
  • 打赏
  • 举报
回复
排序後結果集是一樣的,但D的順序與cube中一致。期待專家解釋。

2,668

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 认证与考试
社区管理员
  • 认证与考试社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧