{"id":3870,"date":"2024-04-09T09:37:55","date_gmt":"2024-04-09T02:37:55","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=3870"},"modified":"2024-04-09T09:38:29","modified_gmt":"2024-04-09T02:38:29","slug":"sql-server-outer-apply","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/","title":{"rendered":"SQL Server OUTER APPLY"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the SQL Server <code>OUTER APPLY<\/code> clause to perform a left join of a table with a table-valued function or a correlated subquery.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-sql-server-outer-apply-clause'>Introduction to the SQL Server OUTER APPLY clause <a href=\"#introduction-to-the-sql-server-outer-apply-clause\" class=\"anchor\" id=\"introduction-to-the-sql-server-outer-apply-clause\" title=\"Anchor for Introduction to the SQL Server OUTER APPLY clause\">#<\/a><\/h2>\n\n\n\n<p>The <code>OUTER APPLY<\/code> clause allows you to perform a left join of a table with a <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-user-defined-functions\/sql-server-table-valued-functions\/\">table-valued function<\/a> or a <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-correlated-subquery\/\">correlated subquery<\/a>.<\/p>\n\n\n\n<p class=\"note\">In SQL Server, a table-valued function is a <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-user-defined-functions\/\">user-defined function<\/a> that <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-user-defined-functions\/sql-server-table-valued-functions\/\">returns multiple rows as a table<\/a>.<\/p>\n\n\n\n<p>The <code>OUTER APPLY<\/code> clause works like a <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-left-join\/\">LEFT JOIN<\/a><\/code> clause. However, instead of joining two tables, the <code>OUTER APPLY<\/code> clause joins a table with a table-valued function or a correlated subquery.<\/p>\n\n\n\n<p>The following shows the syntax of the <code>OUTER APPLY<\/code> clause:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  select_list\n<span class=\"hljs-keyword\">FROM<\/span>\n  table1\n  <span class=\"hljs-keyword\">OUTER<\/span> <span class=\"hljs-keyword\">APPLY<\/span> table_function(table1.column) <span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">alias<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>table1<\/code> is the main table from which you want to join.<\/li>\n\n\n\n<li><code>table_function<\/code> is the table-valued function to apply to each row. Alternatively, you can use a correlated subquery.<\/li>\n\n\n\n<li><code>column<\/code> is the column from <code>table1<\/code> that will be passed as a parameter to the <code>table_function<\/code>.<\/li>\n\n\n\n<li><code>alias<\/code> is the alias for the result set returned by the <code>table_function<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>In this query, the <code>OUTER APPLY<\/code> clause will apply the <code>table_function<\/code> to each row from the <code>table1<\/code>, or execute a correlated subquery for each row from the <code>table1<\/code>.<\/p>\n\n\n\n<p>If there are no corresponding rows from the result set of the table-valued function or correlated subquery, the <code>OUTER APPLY<\/code> clause will use NULL for &#8220;right table&#8221; to create a new row in the result set.<\/p>\n\n\n\n<p>In practice, you should use the <code>OUTER APPLY<\/code> clauses when you cannot use <code>LEFT JOIN<\/code> clauses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='sql-server-outer-apply-clause-examples'>SQL Server OUTER APPLY clause examples <a href=\"#sql-server-outer-apply-clause-examples\" class=\"anchor\" id=\"sql-server-outer-apply-clause-examples\" title=\"Anchor for SQL Server OUTER APPLY clause examples\">#<\/a><\/h2>\n\n\n\n<p>Let&#8217;s take some examples of using the <code>OUTER APPLY<\/code> clause.<\/p>\n\n\n\n<p>We&#8217;ll use the <code>production.products<\/code> and <code>production.order_items<\/code> tables from the <a href=\"https:\/\/www.sqlservertutorial.net\/getting-started\/sql-server-sample-database\/\">sample database<\/a> for the demonstration:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"456\" height=\"169\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png\" alt=\"SQL Server OUTER APPLY clause - Sample Tables\" class=\"wp-image-146\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png 456w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items-300x111.png 300w\" sizes=\"auto, (max-width: 456px) 100vw, 456px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id='1-using-the-sql-server-outer-apply-clause-to-join-a-table-with-a-correlated-subquery'>1) Using the SQL Server OUTER APPLY clause to join a table with a correlated subquery <a href=\"#1-using-the-sql-server-outer-apply-clause-to-join-a-table-with-a-correlated-subquery\" class=\"anchor\" id=\"1-using-the-sql-server-outer-apply-clause-to-join-a-table-with-a-correlated-subquery\" title=\"Anchor for 1) Using the SQL Server OUTER APPLY clause to join a table with a correlated subquery\">#<\/a><\/h3>\n\n\n\n<p>The following example uses the <code>OUTER APPLY<\/code> clause to join the <code>production.products<\/code> table with a correlated subquery to retrieve the product name, quantity, and discount of the products with the brand id 1 in the latest orders:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  p.product_name,\r\n  r.quantity,\r\n  r.discount\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  production.products p <span class=\"hljs-keyword\">OUTER<\/span> <span class=\"hljs-keyword\">apply<\/span> (\r\n    <span class=\"hljs-keyword\">SELECT<\/span>\r\n      top <span class=\"hljs-number\">1<\/span> i.*\r\n    <span class=\"hljs-keyword\">FROM<\/span>\r\n      sales.order_items i\r\n      <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> sales.orders o <span class=\"hljs-keyword\">ON<\/span> o.order_id = i.order_id\r\n    <span class=\"hljs-keyword\">WHERE<\/span>\r\n      product_id = p.product_id\r\n    <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n      order_date <span class=\"hljs-keyword\">DESC<\/span>\n  ) r\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n  p.brand_id = <span class=\"hljs-number\">1<\/span>\r\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n  r.quantity;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">product_name                                          | quantity | discount\r\n<span class=\"hljs-comment\">-----------------------------------------------------------------------<\/span>\r\nElectra Townie Go! 8i Ladies' - 2018                  | NULL     | NULL\r\nElectra Savannah 1 (20-inch) - Girl's - 2018          | NULL     | NULL\r\nElectra Sweet Ride 1 (20-inch) - Girl's - 2018        | NULL     | NULL\r\nElectra Townie Original 21D - 2018                    | 1        | 0.20\r\nElectra Townie Balloon 7i EQ - 2018                   | 1        | 0.10\r\nElectra Townie Balloon 3i EQ - 2017\/2018              | 1        | 0.10\r\nElectra Townie Balloon 8D EQ - 2016\/2017\/2018         | 1        | 0.07<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>How it works.<\/p>\n\n\n\n<p>For each row from the <code>production.products<\/code>  table, the <code>OUTER APPLY<\/code> executes the following <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-correlated-subquery\/\">correlated subquery<\/a> to retrieve the discount and quantity of the latest orders:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\r\n  TOP <span class=\"hljs-number\">1<\/span> i.*\r\n<span class=\"hljs-keyword\">FROM<\/span>\r\n  sales.order_items i\r\n  <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> sales.orders o <span class=\"hljs-keyword\">ON<\/span> o.order_id = i.order_id\r\n<span class=\"hljs-keyword\">WHERE<\/span>\r\n  product_id = p.product_id\r\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n  order_date <span class=\"hljs-keyword\">DESC<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='2-using-the-outer-apply-clause-to-join-a-table-with-a-table-valued-function'>2) Using the OUTER APPLY clause to join a table with a table-valued function <a href=\"#2-using-the-outer-apply-clause-to-join-a-table-with-a-table-valued-function\" class=\"anchor\" id=\"2-using-the-outer-apply-clause-to-join-a-table-with-a-table-valued-function\" title=\"Anchor for 2) Using the OUTER APPLY clause to join a table with a table-valued function\">#<\/a><\/h3>\n\n\n\n<p>First, <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-user-defined-functions\/sql-server-table-valued-functions\/\">define a table-valued function<\/a> that returns latest order items of a product specified by the product id:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> <span class=\"hljs-keyword\">FUNCTION<\/span> GetLatestQuantityDiscount (@product_id <span class=\"hljs-built_in\">INT<\/span>) \n<span class=\"hljs-keyword\">RETURNS<\/span> <span class=\"hljs-keyword\">TABLE<\/span> \n<span class=\"hljs-keyword\">AS<\/span> <span class=\"hljs-keyword\">RETURN<\/span> (\r\n  <span class=\"hljs-keyword\">SELECT<\/span>\r\n    TOP <span class=\"hljs-number\">1<\/span> i.*\r\n  <span class=\"hljs-keyword\">FROM<\/span>\r\n    sales.order_items i\r\n    <span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> sales.orders o <span class=\"hljs-keyword\">ON<\/span> o.order_id = i.order_id\r\n  <span class=\"hljs-keyword\">WHERE<\/span>\r\n    product_id = @product_id\r\n  <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\r\n    order_date <span class=\"hljs-keyword\">DESC<\/span>\r\n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, use the <code>OUTER APPLY<\/code> clause with the table-valued function <code>GetLatestQuantityDiscount<\/code> to retrieve the latest quantity and discount of each product in the <code>production.products<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span>\n  p.product_name,\n  r.quantity,\n  r.discount\n<span class=\"hljs-keyword\">FROM<\/span>\n  production.products p \n<span class=\"hljs-keyword\">OUTER<\/span> <span class=\"hljs-keyword\">APPLY<\/span> GetLatestQuantityDiscount(p.product_id) r\n<span class=\"hljs-keyword\">WHERE<\/span>\n  p.brand_id = <span class=\"hljs-number\">1<\/span>\n<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span>\n  r.quantity;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>It returns the same result as the query that joins with the correlated subquery above.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>OUTER APPLY<\/code> operator to perform a left join of a table with the table-valued function or a correlated subquery.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3870\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/\"\n\t\t\t\tdata-post-title=\"SQL Server OUTER APPLY\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3870\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/\"\n\t\t\t\tdata-post-title=\"SQL Server OUTER APPLY\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to use the SQL Server OUTER APPLY clause to join a table with a table-valued function or a correlated subquery.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":100,"menu_order":28,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3870","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server OUTER APPLY<\/title>\n<meta name=\"description\" content=\"How to use the SQL Server OUTER APPLY clause to perform a left join of a table with a table-valued function or a correlated subquery.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server OUTER APPLY\" \/>\n<meta property=\"og:description\" content=\"How to use the SQL Server OUTER APPLY clause to perform a left join of a table with a table-valued function or a correlated subquery.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-09T02:38:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/\",\"name\":\"SQL Server OUTER APPLY\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/products-order_items.png\",\"datePublished\":\"2024-04-09T02:37:55+00:00\",\"dateModified\":\"2024-04-09T02:38:29+00:00\",\"description\":\"How to use the SQL Server OUTER APPLY clause to perform a left join of a table with a table-valued function or a correlated subquery.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/products-order_items.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/products-order_items.png\",\"width\":456,\"height\":169,\"caption\":\"products order_items\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/sql-server-outer-apply\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Basics\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-basics\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Server OUTER APPLY\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server OUTER APPLY","description":"How to use the SQL Server OUTER APPLY clause to perform a left join of a table with a table-valued function or a correlated subquery.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server OUTER APPLY","og_description":"How to use the SQL Server OUTER APPLY clause to perform a left join of a table with a table-valued function or a correlated subquery.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2024-04-09T02:38:29+00:00","og_image":[{"url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/","name":"SQL Server OUTER APPLY","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png","datePublished":"2024-04-09T02:37:55+00:00","dateModified":"2024-04-09T02:38:29+00:00","description":"How to use the SQL Server OUTER APPLY clause to perform a left join of a table with a table-valued function or a correlated subquery.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/products-order_items.png","width":456,"height":169,"caption":"products order_items"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-outer-apply\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Basics","item":"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/"},{"@type":"ListItem","position":3,"name":"SQL Server OUTER APPLY"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=3870"}],"version-history":[{"count":3,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3870\/revisions"}],"predecessor-version":[{"id":3875,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3870\/revisions\/3875"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/100"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=3870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}