是否可以在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;
答案 0 :(得分:1)
将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;