题解 | #返回每个顾客不同订单的总金额#

返回每个顾客不同订单的总金额

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

对于初学者有点逆天 1.表.列名 列名,酱紫写第一次见到 2.应该是o表和tb表,其中tb表是自己定义出来的,表 别名,表 别名,不用as 的吗 3.wehere的时候为什么不用“表.列名 列名 = 表.列名 列名”了只需要“表.列名 = 表.列名”?

    o.cust_id cust_id,
    tb.total_ordered total_ordered
from(
    select 
        order_num,
        sum(item_price * quantity) as total_ordered
    from 
        OrderItems
    Group by 
        order_num
    )tb,
    Orders o
where tb.order_num = o.order_num
order by total_ordered DESC;
全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务