Hello. I was wondering if it is possible to insert a column as a parameter in a user-defined function and have it return a value that you calculate within the function?
Say I have a column in a table with multiple values. I want to insert this column into a UDF and then use this function in a select statement to give me one value (say the standard deviation of that column).
select dbo.fn_StandardDeviation(column, @percent) from table
(dbo.fn_StandardDeviation is my function)
I want my function to have two parameters, the column (say it has 10 rows), and a parameter @percent float. Is this possible? Do I have to use a user-defined aggregate function instead? (i've heard of it but don't know how to use it).
I understand the types and it seems to me that the function is calculating whatever math function one row at a time. What I'm trying to do is pass in an array (if that's even possible) and having it return a numeric value (one row, one column).
For example: I want to pass in a column that has 10 rows (say numbers 1-10) and I want my function to calculate the minimum of that column. When I call my function with a select statement, it returns one row, one column with the value 1 (minimum of 1-10).