题解 | #确定最佳顾客的另一种方式(二)#

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

http://www.nowcoder.com/practice/b5766f970ae64ac7944f37f5b47107aa

  • SELECT 后面跟着聚合函数字段的话,后面其他的字段都得是分组条件。 例如有聚合函数SUM,按照...分组,这一组的总数是...
SELECT cust_name, temp.total_price
FROM Customers c
JOIN 
    (SELECT cust_id, SUM(item_price*quantity) AS total_price
    FROM OrderItems ot
    LEFT JOIN Orders o ON ot.order_num = o.order_num
    GROUP BY cust_id) AS temp
ON    c.cust_id = temp.cust_id
WHERE temp.total_price >= 1000
ORDER BY temp.total_price ASC
全部评论

相关推荐

05-22 09:23
门头沟学院 Java
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-07 11:35
程序员小白条:话太多,没实力和学历,差不多回答回答就行了,身份地位不一样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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