题解 | #列出供应商及其可供产品的数量#

列出供应商及其可供产品的数量

https://www.nowcoder.com/practice/17f22851cf204019b51a36761a3afc79

select a.vend_id,count(prod_id) from Vendors a
left join Products b on a.vend_id=b.vend_id
group by vend_id
union 
select c.vend_id,count(prod_id) from Vendors c
right join Products d on c.vend_id=d.vend_id
where d.vend_id is null
group by vend_id
order by vend_id
根据题目的要求使用OUTER JOIN 的解法如上
全部评论

相关推荐

06-19 19:06
门头沟学院 Java
码农索隆:别去东软,真学不到东西,真事
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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