下圖14.3這個案例的上半部分,查詢訂購超過10件物品顧客的姓名,案例中是如何實作分組計數的?
uj5u.com熱心網友回復:
這書寫錯了吧uj5u.com熱心網友回復:
--1. 子查詢根據客戶id,統計每個客戶的訂購數量。(o.cust_id = c.cust_id)
-- 相當于每個記錄都單獨統計一次,所以不用分組。
select c.cust_name
from customer_tbl c
where 10<(
select sum(o.qty)
from orders_tbl o
where o.cust_id = c.cust_id
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/46298.html
標籤:基礎類
