试试这个:
select dateCol, fkid, sector, sum(value) over (partition by fkid, sector) / (select count(distinct dateCol) from @MyTable where fkid = t.fkid)from @MyTable t
或者
select fkid, sector, sum(value) / (select count(distinct dateCol) from @MyTable where fkid = t.fkid)from @MyTable tgroup by fkid, sector
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)