9、(5-5) choose the best answer
View the Exhibit and examine the structure of the SALES and STORES tables.
You want to display the store name and the total quantity sold for each item in the store.

Which SQL statement will give the required output?
A) SELECT str.name, s1.items_id, SUM(s1.quantity)
FROM sales s1 JOIN stores str
ON (s1.store_id = str.store_id)
GROUP BY str.name, s1.items_id, s1.quantity;

B) SELECT str.name, s1.items_id, SUM(s1.quantity)
FROM sales s1 JOIN stores str
ON (s1.store_id = str.store_id)
GROUP BY str.name, s1.items_id;

C) SELECT str.name, s1.items_id,
(SELECT SUM(quantitY)
FROM sales sls
ON sls.store_id = s1.store_id
GROUP BY sls.store_id)
FROM sales s1 JOIN stores str
ON (s1.store_id = str.store_id);

D) SELECT str.name, s1.items_id, SUM(s1.quantity)
FROM sales s1 JOIN stores str ON (s1.store id = str.store_id)
GROUP BY s1.items_id, s1.quantity;

Answer:B
(解析:分组函数的最基本特点,没有出现在分组函数中的列必须要出现在 group by 子句中。)

最新文章

  1. 【转】最流行的编程语言JavaScript能做什么?
  2. Lab_7_Automating_v2.5
  3. Spark RDD到底是个什么东西
  4. SharedPreferences详解(三)——存取图片
  5. magento中如何实现产品图片放大效果
  6. Ubuntu上安装mono并进行C#代码测试
  7. Redo与undo在开发中的使用
  8. 快速排序算法 Quick sort
  9. NVMe 与 AHCI
  10. LINUX系统中动态链接库的创建与使用
  11. poj1961 kmp
  12. SqlServer排序(null值,和非空值排列顺序)
  13. 基于Windows环境下cmd/编译器无法输入中文,显示中文乱码解决方案
  14. 推荐多线程下载工具axel替代wget
  15. alias命令详解
  16. H3C505
  17. Eclipse 中打包插件 Fat Jar 的安装与使用
  18. SRM-供应商关系管理-组织模式
  19. Django实战(15):Django实现RESTful web service
  20. 透析Java本质-谁创建了对象,this是什么

热门文章

  1. PHP 数组中出现中文乱码,json_encode返回结果为null 或false
  2. a different object with the same identifier value was already associated with the session解决方案
  3. 03.什么是Lucene全文检索的原理01
  4. 【LA3126 训练指南】出租车 【DAG最小路径覆盖】
  5. 一些好用的 Oracle 批处理和语句
  6. 695. Max Area of Island最大岛屿面积
  7. ActiveMQ 使用文档
  8. spring4-5-事务管理
  9. Mysql中自定义函数编程
  10. p2598 [ZJOI2009]狼和羊的故事