# UDF problem - Microsoft SQL / MS SQL Server

Hello ! I made a function that calculates percentile and returns decimal But one slight problem is that it's not dynamic and I want the function to some how look at every row of employee id and return values for every row of employeeID Thank you TKim select distinct employeeid, dbo.oagg(employeeid) from orders...

1. ## UDF problem

Hello !

I made a function that calculates percentile
and returns decimal

But one slight problem is that it's not dynamic and I want the function to
some how look at
every row of employee id and return values for every row of employeeID

Thank you
TKim

select distinct employeeid, dbo.oagg(employeeid)
from orders

Tkim Guest

2. ## Re: UDF problem

I dont think if there is any problem in your statement ... It would be nice if you can tell us your output also ...

--
HTH,
Vinod Kumar
SCT Software Solutions
http://www32.brinkster.com/sqlvinod

"Tkim" <com> wrote in message news:iFlRa.5524\$prod.itd.earthlink.net...
Vinodk Guest

3. ## Re: UDF problem

Hi

I don't have the UDF SQL code with me right now.

But UDF basically accepts 2 parameters
which will be used in select statement
WHERE COL1 = coalesce(var1, COL1) and
COL2 = coalesce(var1, COL2)

and locates the position by .9(count(COL3)+ 1) (I think this is the formula)

and uses the cursor to absolute fetch the 2 data (one in nth position with
and other from n+1 th position).
If the modulus is 0, then it just returns the value in nth position, else it
does further calculation and returns a scalar value.

So there will be one value, like 90.000 for 90th percentile.

What I want to do is to use the above UDF as subquery in Select statement so
I don't have to manually feed in the value to the UDF (Some how make the
paramters equal to the identifiers(columns) that is being selected in main
query)

Thank you

"Vinodk" <com> wrote in message
news:eGWTm\$phx.gbl...
I dont think if there is any problem in your statement ... It would be nice
if you can tell us your output also ...

--
HTH,
Vinod Kumar
SCT Software Solutions
http://www32.brinkster.com/sqlvinod

"Tkim" <com> wrote in message

Tkim Guest

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•