Hello Welcome to Sberry blog. This post gives you a quick snap of what APPLY operator in sql server. Learn now with Sberry.
APPLY operator in a Transact-SQL query is used to join a table to a table-valued function so the function is evoked for each row returned from the table.
The APPLY operator can take one of two forms: CROSS APPLY or OUTER APPLY.
The CROSS APPLY operator returns rows from the primary (outer) table only if the table-value function produces a result set.
The OUTER APPLY form, on the other hand, returns all rows from the outer table, even if the function produces no results.
SELECT sp.FirstName + ' ' + sp.LastName AS FullName,
Sales.vSalesPerson AS sp
fn_sales(sp.BusinessEntityID) AS fn
sp.LastName, fn.SalesAmount DESC
Viola!! Bye – Bye.