隐式、显式

确定最佳顾客的另一种方式(二)

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;

全部评论

相关推荐

程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
06-02 15:17
门头沟学院 Java
心爱的idea:怎么会呢 应该是打招呼有问题 问就说实习6个月全国可飞随时到岗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务