试试这个:
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



