Here is table-value function I have declared like:
CREATE FUNCTION fn_GetMedian(@List TypeMedian READONLY) RETURNS INT AS BEGIN RETURN ( Select ( ( Select Top 1 Value From ( Select Top 50 Percent Value From @List Where Value Is NOT NULL Order By Value ) As A Order By Value DESC ) + ( Select Top 1 Value From ( Select Top 50 Percent Value From @List Where Value Is NOT NULL Order By Value DESC ) As A Order By Value Asc ) ) / 2 ) END Here is code temp table and query I'm executing:
DECLARE @Temp Table (ID INT,ID2 INT) select fn_GetMedian(ID) from @Temp But, I'm getting error as:
Msg 195, Level 15, State 10, Line 9
'fn_GetMedian' is not a recognized function name.
This question is related to:
INT. This usage will not work. Please see your other, related Question for several examples of how to accomplish a Median function / aggregate.