题解 | #商品交易(网易校招笔试真题)#

商品交易(网易校招笔试真题)

https://www.nowcoder.com/practice/f257dfc1b55e42e19eec004aa3cb4174

#goods全表+总购买个数
#质量<50
#购买总数>20

select
    id
    ,name
    ,weight
    ,total
from (
        select
            distinct
            goods_id
            ,sum(count)over(partition by goods_id) total#购买总个数
        from trans
        ) n
    join (
            select
                *
            from goods
            where weight<50#质量<50
            ) w
        on w.id=n.goods_id
where total>=20#购买总数>20

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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