Hopefully the title makes some amount of sense. Basically I have a scalar function that takes a user defined table as input, f_doCalc(@MyUserDefinedTableType). The table type has 2 columns, theValue and theDate. Now assume I have a large table, called TableOfValue of values like so:
What I want to do is call my f_doCalc with the dates and values from all previous dates. So the first row would be called with a @MyUserDefinedTableType containing
The second with a @MyUserDefinedTableType containing
and so on.
Is this somehow possible to accomplish without using a WHILE loop? Such as of the form
SELECT Values, Date, f_doCalc( ... ) FROM TableOfValue