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

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

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

# 先作质量筛选
select *
from goods
where weight < 50

# 连接goods表和trans表再作购买数目的筛选
select goods_id id, name, weight, sum(count) total
from (
    select *
    from goods
    where weight < 50
) t1
join trans t
on t1.id = t.goods_id
group by goods_id
having sum(count) > 20
order by id;

全部评论

相关推荐

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