CROSS APPLY invokes a table-valued function for each row in an outer table expression, returning a unified result set out of all the results returned by the individual invocations of the table-valued function. The columns in the outer table are used as arguments to the table-valued function. If the table-valued function returns an empty set for a given outer row, that outer row is not returned in the result.
For example, the table-valued function in Listing 45.44 accepts
ProductID and an integer as arguments and returns a list of the top N largest orders for that store. The number of rows returned is determined by the value passed to the second parameter. If you call this function with
ProductID and a number of rows, it returns that ...