我错过了什么?
此查询一遍又一遍地返回重复数据。计数对于一个完整的总数是正确的,但我期待一行,但我得到的值重复了大约 40 次。有任何想法吗?
SELECT BrandId
,SUM(ICount) OVER (PARTITION BY BrandId )
FROM Table
WHERE DateId = 20130618
我明白了吗?
BrandId ICount
2 421762
2 421762
2 421762
2 421762
2 421762
2 421762
2 421762
1 133346
1 133346
1 133346
1 133346
1 133346
1 133346
1 133346
我错过了什么?
我无法删除分区,因为整个查询是这样的:
SELECT BrandId
,SUM(ICount) OVER (PARTITION BY BrandId)
,TotalICount= SUM(ICount) OVER ()
,SUM(ICount) OVER () / SUM(ICount) OVER (PARTITION BY BrandId) as Percentage
FROM Table
WHERE DateId = 20130618
这会返回:
BrandId (No column name) TotalICount Percentage
2 421762 32239892 76
2 421762 32239892 76
2 421762 32239892 76
2 421762 32239892 76
2 421762 32239892 76
2 421762 32239892 76
我希望输出这样的东西而不必使用不同的:
BrandId (No column name) TotalICount Percentage
2 421762 32239892 76
9 1238442 32239892 26
10 1467473 32239892 21