我想要sum(distinct xxx)over(partition by yyy)这样的效果 , 但编译器不允许,Use of DISTINCT is not allowed with the OVER clause., 有啥其他办法实现我想要的效果吗???
------解决方案--------------------
窗口函数好像还不支持distinct,使用子查询来变通实现吧
with Test (xxx, yyy) as
(
select 1, 'a' union all
select 1, 'a' union all
select 2, 'b'
)
select xxx, yyy
, distinctSum = (select sum(distinct xxx) from Test as T1 where T1.yyy = Test.yyy)
from Test