隐式、显式
确定最佳顾客的另一种方式(二)
https://www.nowcoder.com/practice/b5766f970ae64ac7944f37f5b47107aa
select
c.cust_name,sum(oi.quantity * oi.item_price) total_price -- 查询的字段
from Orders o,OrderItems oi,Customers c -- 三张表并成一张
where o.order_num = oi.order_num and o.cust_id = c.cust_id -- 连接的基础条件
group by c.cust_name -- 以顾客名字进行分组
having total_price >= 1000 -- 消费金额不低于$1000
order by total_price;
-- 显式
select
c.cust_name,sum(oi.quantity * oi.item_price) total_price
from Orders s
-- 连接条件
join OrderItems oi using(order_num)
join Customers c using(cust_id)
group by c.cust_name
having total_price >= 1000
order by 2;