2

aggregate functions are useful, e.g.:

select FinancialYear, PLFolder, Sum(PLDelta) SumDelta 
from PL group by FinancialYear, PLFolder

however, sometimes I need do more complex calculation, such as, calculating the volatility.

This could be done by a User Defined Aggregate Function, programmed in C#, compiled as a CLR assembly, and then imported into MSSQL.

Is it possible to do it in pure T-SQL?

rs.
  • 26,707
  • 12
  • 68
  • 90
athos
  • 6,120
  • 5
  • 51
  • 95

1 Answers1

8

No.

The only way to write custom aggregates is through SQLCLR. There are technical reasons behind this limitation, primarily related to the need of an aggregate to have state.

Remus Rusanu
  • 288,378
  • 40
  • 442
  • 569