Thursday, March 29, 2012

Creating an aggregate function

Hi,
Is there a way to create an aggeregate function in MS SQL?
For example, if you wanted to re-implement fucntion SUM(), how would you do
that?
Any ideas would be highly appreciated!
Thank you,
AndreyThis functionality is planned for the upcoming release of SQL Server 2005.
You can write aggregate functions in a CLR language.
Hope this helps.
Dan Guzman
SQL Server MVP
"MuZZy" <leyandrew@.yahoo.com> wrote in message
news:TJCdnXEc-KWYpKffRVn-pA@.comcast.com...
> Hi,
> Is there a way to create an aggeregate function in MS SQL?
> For example, if you wanted to re-implement fucntion SUM(), how would you
> do that?
> Any ideas would be highly appreciated!
> Thank you,
> Andrey|||You won't be able to do that with SQL Server 2000, unfortunately. Stay
tuned for SQL Server 2005.
On 3/17/05 9:12 PM, in article TJCdnXEc-KWYpKffRVn-pA@.comcast.com, "MuZZy"
<leyandrew@.yahoo.com> wrote:

> Hi,
> Is there a way to create an aggeregate function in MS SQL?
> For example, if you wanted to re-implement fucntion SUM(), how would you d
o
> that?
> Any ideas would be highly appreciated!
> Thank you,
> Andrey|||Andrey,
As others mentioned, no support for creating new custom aggregates, but
there are several techniques that you can implement in SQL Server 2000.
These include Pivoting if the number of elements is small enough, and other
techniques for a large number of elements depending on the specific
calculation you are trying to achieve.
If you have a specific custom aggregate you want to calculate, and would
like to share, maybe we can come up with a solution.
BG, SQL Server MVP
www.SolidQualityLearning.com
"MuZZy" <leyandrew@.yahoo.com> wrote in message
news:TJCdnXEc-KWYpKffRVn-pA@.comcast.com...
> Hi,
> Is there a way to create an aggeregate function in MS SQL?
> For example, if you wanted to re-implement fucntion SUM(), how would you
> do that?
> Any ideas would be highly appreciated!
> Thank you,
> Andrey|||>>For example, if you wanted to re-implement function SUM(), how would
you do that? <<
You can put expressions inside the existing aggregate functions and do
quite a lot. For example, you can google some old posts on how to
write a product aggregate with logs and exponent functions.
If you have a particular one you want to implement, post a spec and we
will see what we can do.

No comments:

Post a Comment