Do you have any aggregate functions that you have implemented because the standard ones were not good enough?
3 Answers
An aggregate function for SQL Server that produces a comma-separated list of values.
Title
-----------------
The Hobbit
The Two Towers --> The Hobbit, The Two Towers, Leaf by Niggle
Leaf by Niggle
Here's my implementation: A SQL CLR user-defined aggregate - notes on creating and debugging
-
Very useful. I have this too. I called it toCSV, but I don't really like that name. What did you call yours? Any better ideas? Dec 12, 2010 at 18:26
-
@PAUL Mansour I named mine
Concat
(short for concatenate), but it's not a perfect name either. Dec 12, 2010 at 18:36 -
1SQL Server has some interesting string concatenation performance. Here's some performance tests between
select @var = @var + column
style SQL and a user-defined aggregate using a .NETStringBuilder
: graphs SQL-based concat gets dramatically slower once the total string length goes over 500k chars.– geofftnzSep 26, 2011 at 22:09
Yes. In Oracle I've implemented a kind of group_concat because it is unavailable in Oracle. I've made a couple different versions which do a simple concat with comma-delimiting strings. Another does the same, only sorted. And there's another one that doesn't use a comma, but a special character so the results can be processed more easily when the values themselves might contain comma's too.
Weighted Average
PercentAcross - This is the sum of X where a condition is true, divided by the sum of X.