首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用parent_category_id的产品计数

使用parent_category_id的产品计数
EN

Stack Overflow用户
提问于 2015-08-25 14:01:44
回答 1查看 29关注 0票数 0

我有两个表1: cat_a

表2:prod_a

输出必须是

代码语言:javascript
复制
When category_id =1 then product_id count must be 7 
when category_id = 3 then product_id count must be 5
when category_id = 6 then product_id count must be 3
when category_id = 7 then product_id count must be 2
when category_id = 5 then product_id count must be 2

请帮帮我。我已经搜索了很多问题和答案以及论坛。找不到确切的解决方案。我不想要填鸭式的答案。请注明提示或带答案的方法。

EN

回答 1

Stack Overflow用户

发布于 2015-08-25 14:18:35

我的问题解决了。

代码语言:javascript
复制
SELECT count( product_id)
FROM prod_A 
WHERE  category_id IN (SELECT category_id FROM cat_A  START WITH category_id = <i_category_id>
     CONNECT BY PRIOR category_id = parent_catogory);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32196580

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档