{"id":1770,"date":"2018-09-10T07:53:11","date_gmt":"2018-09-10T14:53:11","guid":{"rendered":"https:\/\/sqltutorial.org\/?page_id=1770"},"modified":"2025-02-04T07:06:23","modified_gmt":"2025-02-04T14:06:23","slug":"sql-lead","status":"publish","type":"page","link":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/","title":{"rendered":"SQL LEAD Function"},"content":{"rendered":"\r\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to access data of a row at a specific physical offset that follows the current row using the SQL <code>LEAD()<\/code> function.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='overview-of-sql-lead-function'>Overview of SQL LEAD() function <a href=\"#overview-of-sql-lead-function\" class=\"anchor\" id=\"overview-of-sql-lead-function\" title=\"Anchor for Overview of SQL LEAD() function\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>SQL <code>LEAD()<\/code> is a <a href=\"https:\/\/www.sqltutorial.org\/sql-window-functions\/\">window function<\/a> that provides access to a row at a specified physical offset that follows the current row.<\/p>\r\n\r\n\r\n\r\n<p>For example, by using the <code>LEAD()<\/code> function, from the current row, you can access data from the next row, the second row that follows the current row, the third row that follows the current row, and so on.<\/p>\r\n\r\n\r\n\r\n<p>The <code>LEAD()<\/code> function can be very useful for calculating the difference between the value of the current row and the value of the following row.<\/p>\r\n\r\n\r\n\r\n<p>The syntax of the <code>LEAD()<\/code> function is as follows:<\/p>\r\n\r\n\r\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\">LEAD(return_value &#91;,offset&#91;, default ]]) OVER (\r\n    PARTITION BY expr1, expr2,...\r\n\tORDER BY expr1 &#91;ASC | DESC], expr2,...\r\n)\r\n<\/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>\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='%c2%a0return_value'>\u00a0return_value <a href=\"#%c2%a0return_value\" class=\"anchor\" id=\"%c2%a0return_value\" title=\"Anchor for \u00a0&lt;code&gt;return_value&lt;\/code&gt;\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The return value of the following row offsets from the current row.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='%c2%a0offset'>\u00a0offset <a href=\"#%c2%a0offset\" class=\"anchor\" id=\"%c2%a0offset\" title=\"Anchor for \u00a0&lt;code&gt;offset&lt;\/code&gt;\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The number of rows forwards from the current row from which to access data. The <code>offset<\/code> must be a non-negative integer. If you don&#8217;t specify <code>offset<\/code>, it defaults to 1.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='%c2%a0default'>\u00a0default <a href=\"#%c2%a0default\" class=\"anchor\" id=\"%c2%a0default\" title=\"Anchor for \u00a0&lt;code&gt;default&lt;\/code&gt;\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The function returns <code>default<\/code> if the <code>offset<\/code> goes beyond the scope of the partition. If you do not specify <code>default<\/code>, <code>NULL<\/code> is returned.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='%c2%a0partition-by-clause'>\u00a0PARTITION BY clause <a href=\"#%c2%a0partition-by-clause\" class=\"anchor\" id=\"%c2%a0partition-by-clause\" title=\"Anchor for \u00a0&lt;code&gt;PARTITION BY&lt;\/code&gt; clause\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The <code>PARTITION BY<\/code> clause divides rows of the result set into partitions to which the <code>LEAD()<\/code> function applies. If you do not specify the <code>PARTITION BY<\/code> clause, the whole result set is treated as a single partition.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='order-by-clause'>ORDER BY clause <a href=\"#order-by-clause\" class=\"anchor\" id=\"order-by-clause\" title=\"Anchor for ORDER BY clause\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The <code>ORDER BY<\/code> clause sorts the rows in each partition to which the <code>LEAD()<\/code> function applies.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='sql-lead-function-examples'>SQL LEAD() function examples <a href=\"#sql-lead-function-examples\" class=\"anchor\" id=\"sql-lead-function-examples\" title=\"Anchor for SQL &lt;code&gt;LEAD()&lt;\/code&gt; function examples\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<p>We will use the <code>employees<\/code> table from the <a href=\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\">sample database<\/a> for demonstration purposes.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='using-sql-lead-function-over-the-result-set-example'>Using SQL LEAD() function over the result set example <a href=\"#using-sql-lead-function-over-the-result-set-example\" class=\"anchor\" id=\"using-sql-lead-function-over-the-result-set-example\" title=\"Anchor for Using SQL LEAD() function over the result set example\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following statement returns, for each employee in the company, the hire date of the employee hired just after:<\/p>\r\n\r\n\r\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\tfirst_name,\r\n\tlast_name, \r\n\thire_date, \r\n\t<span class=\"hljs-keyword\">LEAD<\/span>(hire_date, <span class=\"hljs-number\">1<\/span>) <span class=\"hljs-keyword\">OVER<\/span> (\r\n\t\t<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> hire_date\r\n\t) <span class=\"hljs-keyword\">AS<\/span> next_hired\r\n<span class=\"hljs-keyword\">FROM<\/span> \r\n\temployees;\r\n<\/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>\r\n\r\n\r\n<p>The following shows the output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"304\" height=\"820\" class=\"wp-image-1771\" title=\"SQL LEAD function Over Result Set Example\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png\" alt=\"SQL LEAD function Over Result Set Example\" srcset=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png 304w, https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example-111x300.png 111w\" sizes=\"auto, (max-width: 304px) 100vw, 304px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>In this example, we omitted the <code>PARTITION BY<\/code> clause. Therefore, the whole result was treated as a single partition. The <code>ORDER BY<\/code> clause sorted employees by hire dates in ascending order. The <code>LEAD()<\/code> function is applied to each row in the result set.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id='using-sql-lead-function-over-partition-example'>Using SQL LEAD() function over partition example <a href=\"#using-sql-lead-function-over-partition-example\" class=\"anchor\" id=\"using-sql-lead-function-over-partition-example\" title=\"Anchor for Using SQL LEAD() function over partition example\">#<\/a><\/h3>\r\n\r\n\r\n\r\n<p>The following statement provides, for each employee, the hire date of the employee in the same department who was hired just after:<\/p>\r\n\r\n\r\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\"><span class=\"hljs-keyword\">SELECT<\/span> \r\n\tfirst_name,\r\n\tlast_name, \r\n\tdepartment_name,\r\n\thire_date, \r\n\t<span class=\"hljs-keyword\">LEAD<\/span>(hire_date, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-string\">'N\/A'<\/span>) <span class=\"hljs-keyword\">OVER<\/span> (\r\n\t\t<span class=\"hljs-keyword\">PARTITION<\/span> <span class=\"hljs-keyword\">by<\/span> department_name\r\n\t\t<span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> hire_date\r\n\t) <span class=\"hljs-keyword\">AS<\/span> next_hire_date\r\n<span class=\"hljs-keyword\">FROM<\/span> \r\n\temployees e\r\n<span class=\"hljs-keyword\">INNER<\/span> <span class=\"hljs-keyword\">JOIN<\/span> departments d <span class=\"hljs-keyword\">ON<\/span> \r\n\td.department_id = e.department_id;\r\n<\/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>\r\n\r\n\r\n<p>The following picture shows the partial output:<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"421\" height=\"377\" class=\"wp-image-1772\" title=\"SQL LEAD function Over Partition Example\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Partition-Example.png\" alt=\"SQL LEAD function Over Partition Example\" srcset=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Partition-Example.png 421w, https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Partition-Example-300x269.png 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/figure>\r\n\r\n\r\n\r\n<p>In this example, we used the <code>PARTITION BY<\/code> clause to divide the employees by departments into partitions and use the <code>ORDER BY<\/code> clause to sort\u00a0the employees in each department by hire dates in ascending order.<\/p>\r\n\r\n\r\n\r\n<p>The <code>LEAD()<\/code> function was applied to each sorted partition independently to get the next hire dates of the employees in each department.<\/p>\r\n\r\n\r\n\r\n<p>In this tutorial, you have learned how to use the SQL <code>LEAD()<\/code> function to access data of the forward row from the current row.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id='databases'>Databases <a href=\"#databases\" class=\"anchor\" id=\"databases\" title=\"Anchor for Databases\">#<\/a><\/h2>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><a href=\"https:\/\/www.pgtutorial.com\/postgresql-window-functions\/postgresql-lead\/\" target=\"_blank\" rel=\"noreferrer noopener\">PostgreSQL LEAD function<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.oracletutorial.com\/oracle-analytic-functions\/oracle-lead\/\" target=\"_blank\" rel=\"noreferrer noopener\">Oracle LEAD function<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-window-functions\/sql-server-lead-function\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Server LEAD function<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-window-functions\/mysql-lead-function\/\" target=\"_blank\" rel=\"noreferrer noopener\">MySQL LEAD function<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-lead\/\" target=\"_blank\" rel=\"noreferrer noopener\">SQLite LEAD function<\/a><\/li>\r\n<\/ul>\r\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=\"1770\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/\"\n\t\t\t\tdata-post-title=\"SQL LEAD Function\"\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=\"1770\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/\"\n\t\t\t\tdata-post-title=\"SQL LEAD Function\"\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>This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1707,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1770","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL LEAD() Function<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.\" \/>\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.sqltutorial.org\/sql-window-functions\/sql-lead\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL LEAD() Function\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-04T14:06:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png\" \/>\n\t<meta property=\"og:image:width\" content=\"304\" \/>\n\t<meta property=\"og:image:height\" content=\"820\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/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.sqltutorial.org\/sql-window-functions\/sql-lead\/\",\"url\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/\",\"name\":\"SQL LEAD() Function\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltutorial.org\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png\",\"datePublished\":\"2018-09-10T14:53:11+00:00\",\"dateModified\":\"2025-02-04T14:06:23+00:00\",\"description\":\"This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#primaryimage\",\"url\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png\",\"contentUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png\",\"width\":304,\"height\":820,\"caption\":\"SQL LEAD function Over Result Set Example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltutorial.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Window Functions\",\"item\":\"https:\/\/www.sqltutorial.org\/sql-window-functions\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL LEAD Function\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltutorial.org\/#website\",\"url\":\"https:\/\/www.sqltutorial.org\/\",\"name\":\"SQL Tutorial\",\"description\":\"An Interactive SQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltutorial.org\/?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 LEAD() Function","description":"This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.","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.sqltutorial.org\/sql-window-functions\/sql-lead\/","og_locale":"en_US","og_type":"article","og_title":"SQL LEAD() Function","og_description":"This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.","og_url":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/","og_site_name":"SQL Tutorial","article_modified_time":"2025-02-04T14:06:23+00:00","og_image":[{"width":304,"height":820,"url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/","url":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/","name":"SQL LEAD() Function","isPartOf":{"@id":"https:\/\/www.sqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#primaryimage"},"image":{"@id":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png","datePublished":"2018-09-10T14:53:11+00:00","dateModified":"2025-02-04T14:06:23+00:00","description":"This tutorial shows you how to access data of a row at a specific physical offset that follows the current row using the SQL LEAD() function.","breadcrumb":{"@id":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#primaryimage","url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png","contentUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2018\/09\/SQL-LEAD-function-Over-Result-Set-Example.png","width":304,"height":820,"caption":"SQL LEAD function Over Result Set Example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltutorial.org\/sql-window-functions\/sql-lead\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"SQL Window Functions","item":"https:\/\/www.sqltutorial.org\/sql-window-functions\/"},{"@type":"ListItem","position":3,"name":"SQL LEAD Function"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltutorial.org\/#website","url":"https:\/\/www.sqltutorial.org\/","name":"SQL Tutorial","description":"An Interactive SQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/1770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/comments?post=1770"}],"version-history":[{"count":0,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/1770\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/1707"}],"wp:attachment":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/media?parent=1770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}