在sql/sas中,是否可以在同一个查询中执行多个计数?我正在做下面的工作,很明显我在sku级别得到了响应,因为这是最详细的级别。我想看看所有这些单独不同于发行报价代码的计数:
SELECT DISTINCT
t1.ISSUANCE_OFFER_CODE,
(COUNT(t1.SKU)) AS COUNT_of_SKU,
(COUNT(t1.ASSORTMENT)) AS COUNT_of_ASSORTMENT,
(COUNT(t1.PRODUCT_GROUP)) AS COUNT_of_PRODUCT_GROUP,
(COUNT(t1.DIVISION_NAME))
FROM WORK.OFFERS t1
GROUP BY t1.ISSUANCE_OFFER_CODE;
最佳答案
将DISTINCT
添加到COUNT
s:
SELECT
t1.ISSUANCE_OFFER_CODE,
(COUNT(t1.SKU)) AS COUNT_of_SKU,
(COUNT(DISTINCT t1.ASSORTMENT)) AS COUNT_of_ASSORTMENT,
(COUNT(DISTINCT t1.PRODUCT_GROUP)) AS COUNT_of_PRODUCT_GROUP,
(COUNT(DISTINCT t1.DIVISION_NAME))
FROM WORK.OFFERS t1
GROUP BY t1.ISSUANCE_OFFER_CODE;
关于mysql - 是否可以在同一查询中进行多个计数?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33376436/