我有这样的表格。
RETAIL_SKU STUDIO_NAME REGION MERCHANT SOURCE_TYPE RETOUCH_LEVEL
CCCF9X55FI CCRY1B EU Buy VIP Studio 9
CCCHB1Z8EE PCCL3B NA Buy VIP Studio 9
CCCFECJQ1I LEJ1A EU Buy VIP Studio 9
CCCH296DN0 CCRY1B EU Buy VIP Studio 9
CCCEQR38LQ PCCL3B NA Buy VIP Studio 9
CCCHSC2X0I PCCL3B NA Buy VIP Studio 9
CCCA0IY4OU BV-DE-RETAIL EU Buy VIP Vendor 9
CCCGX64C68 PCCL3B NA Buy VIP Studio 9
CCCG7U7W4O CCRY1B EU Buy VIP Studio 9
我正在寻找像这样的结果
STUDIO_NAME REGION
CCRY1B 3
PCCL3B 4
LEJ1A 1
BV-DE-RETAIL 1
这是我试过的。(但它会引发错误)
SELECT DISTINCT(STUDIO_NAME),COUNT(RETAIL_SKU) FROM Sheet7 WHERE MERCHANT='Buy VIP' AND RETOUCH_LEVEL=9
我刚开始学习Sql,所以我的知识非常少。您的帮助对我很有帮助
更新
str = "SELECT STUDIO_NAME,COUNT(*) REGION FROM [Sheet7$] WHERE MERCHANT='Buy VIP' AND RETOUCH_LEVEL=9 GROUP BY STUDIO_NAME"
rsEx.Open str, ConEx, adOpenKeyset, adLockOptimistic
答案 0 :(得分:3)
请尝试:
SELECT
STUDIO_NAME,
COUNT(*) REGION
FROM Sheet7
WHERE MERCHANT='Buy VIP' AND
RETOUCH_LEVEL=9
GROUP BY STUDIO_NAME