打赏

第10课 分组数据

  • 10.1 数据分组
    • SELECT COUNT(*) AS num_prods
    • FROM products
    • WHERE vend_id = 'DLL01';
  • 10.2 创建分组
    • SELECT vend_id, COUNT(*) AS num_prods
    • FROM products
    • GROUP BY vend_id;
  • 10.3 过滤分组
    • /*SELECT cust_id, COUNT(*) AS orders
    • FROM orders
    • GROUP BY cust_id
    • HAVING COUNT(*) >= 2;*/
    • -----------------------------------------------
    • SELECT vend_id, COUNT(*) AS num_prods
    • FROM products
    • WHERE prod_price >= 4
    • GROUP BY vend_id
    • HAVING COUNT(*) >= 2;
  • 10.4 分组和排序
    • SELECT order_num, COUNT(*) AS items
    • FROM orderitems
    • GROUP BY order_num
    • HAVING COUNT(*) >= 3;
    • ORDER BY items, order_num;
  • 10.5 SELECT子句顺序
    • SELECT/FROM/WHERE/GROUP BY/HAVING/ORDER BY
  • 10.6 小结





posted on 2019-01-18 04:16  XuCodeX  阅读(142)  评论(0编辑  收藏  举报

导航