Oracle 如何获得客户数量,并根据产品显示客户数量?
Oracle 如何获得客户数量,并根据产品显示客户数量?,oracle,Oracle,我可以获得产品的客户数量,但对我来说,很难像上图中所述那样显示。您可以使用左连接和计数功能: select p.product, count(c.name) as cust_count from product p left join customer c on p.product = c.product group by p.product; 这是假设没有任何客户的产品需要零计数 如果不是这样,您可以使用简单聚合: select product, count(*) as cu
我可以获得产品的客户数量,但对我来说,很难像上图中所述那样显示。您可以使用左连接和计数功能:
select p.product,
count(c.name) as cust_count
from product p
left join customer c
on p.product = c.product
group by p.product;
这是假设没有任何客户的产品需要零计数
如果不是这样,您可以使用简单聚合:
select product,
count(*) as cust_count
from customer
group by product;
这不是一个完整的问题。请编辑您的问题并将表格数据作为实际文本,每行缩进4个空格。然后,向我们展示您尝试过的查询,如果没有,则说明无法尝试查询的原因。