{"id":1761,"date":"2018-11-18T17:01:55","date_gmt":"2018-11-18T10:01:55","guid":{"rendered":"http:\/\/www.sqlitetutorial.net\/?page_id=1761"},"modified":"2024-04-16T10:24:37","modified_gmt":"2024-04-16T03:24:37","slug":"sqlite-window-frame","status":"publish","type":"page","link":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/","title":{"rendered":"SQLite Window Frame"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about the SQLite window frame and how to use it to specify a subset of partitions for calculation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction to the SQLite window frame<\/h2>\n\n\n\n<p>Some <a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/\">window functions<\/a> use the window frame in their calculations such as <code><a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-first_value\/\">FIRST_VALUE()<\/a><\/code>, <a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-last_value\/\"><code>LAST_VALUE()<\/code><\/a>, and <code>SUM()<\/code>. A window frame is used to specify how many rows around the current row the window should include.<\/p>\n\n\n\n<p>To define a window frame, you use one of the following syntaxes:<\/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\">{ RANGE | ROWS } frame_start\n{ RANGE | ROWS } BETWEEN frame_start AND frame_end  \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>\n\n\n<p>The <code>frame_start<\/code> can take one of the following options:<\/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\">N PRECEDING\nUNBOUNDED PRECEDING\nCURRENT ROW<\/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>And the <code>frame_end<\/code> can take one of the following options:<\/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\">CURRENT ROW\nUNBOUNDED FOLLOWING\nN FOLLOWING<\/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>The following picture shows the structure of a frame in a partition:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"408\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png\" alt=\"\" class=\"wp-image-1805\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png 579w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame-300x211.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/figure>\n\n\n\n<p>Here is the meaning of each option:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>UNBOUNDED PRECEDING<\/code>: the frame starts at the first row of the partition.<\/li>\n\n\n\n<li><code>N PRECEDING<\/code>: the frame starts at <code>Nth<\/code> rows before the current row.<\/li>\n\n\n\n<li><code>CURRENT ROW<\/code>: is the current row that is being processed.<\/li>\n\n\n\n<li><code>UNBOUNDED FOLLOWING<\/code>: the frame ends at the final row of the partition.<\/li>\n\n\n\n<li><code>M FOLLOWING<\/code>: the frame ends at the <code>Mth<\/code> row after the current row.<\/li>\n<\/ul>\n\n\n\n<p>By default, window functions use the following option:<\/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\">RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW<\/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\">RANGE vs. ROWS<\/h3>\n\n\n\n<p>The <code>ROWS<\/code> specifies the offset of the current row and the frame rows are row numbers. On the other hand, the <code>RANGES<\/code> indicates that the offset of the current row and frame rows are row values.<\/p>\n\n\n\n<p>Note that <code>RANGE<\/code> must be used only with <code>UNBOUNDED<\/code> or <code>CURRENT ROWS<\/code> option.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SQLite window frame examples<\/h2>\n\n\n\n<p>Let&#8217;s take some practical examples of using window frames.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setting up a sample table<\/h3>\n\n\n\n<p>First, <a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-create-table\/\">create a new table<\/a> named <code>SaleInfo<\/code> that stores the sales amounts by year and month for the demonstration:<\/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\">TABLE<\/span> SalesInfo (\n    <span class=\"hljs-keyword\">year<\/span> <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    <span class=\"hljs-keyword\">month<\/span> <span class=\"hljs-built_in\">INT<\/span> <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>,\n    amount <span class=\"hljs-built_in\">NUMERIC<\/span>(<span class=\"hljs-number\">10<\/span>,<span class=\"hljs-number\">2<\/span>),\n    PRIMARY <span class=\"hljs-keyword\">KEY<\/span>(<span class=\"hljs-keyword\">year<\/span>,<span class=\"hljs-keyword\">month<\/span>)\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, <a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-insert\/\">insert some data<\/a> into the <code>SalesInfo<\/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\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> SalesInfo(<span class=\"hljs-keyword\">year<\/span>,<span class=\"hljs-keyword\">month<\/span>,amount)\n<span class=\"hljs-keyword\">VALUES<\/span>(<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">1<\/span>,<span class=\"hljs-number\">100<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">2<\/span>,<span class=\"hljs-number\">120<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">3<\/span>,<span class=\"hljs-number\">120<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">4<\/span>,<span class=\"hljs-number\">110<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">5<\/span>,<span class=\"hljs-number\">130<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">6<\/span>,<span class=\"hljs-number\">140<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">7<\/span>,<span class=\"hljs-number\">150<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">8<\/span>,<span class=\"hljs-number\">120<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">9<\/span>,<span class=\"hljs-number\">110<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">10<\/span>,<span class=\"hljs-number\">150<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">11<\/span>,<span class=\"hljs-number\">170<\/span>),\n    (<span class=\"hljs-number\">2018<\/span>,<span class=\"hljs-number\">12<\/span>,<span class=\"hljs-number\">200<\/span>);<\/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>Third, <a href=\"https:\/\/www.sqlitetutorial.net\/sqlite-select\/\">query data<\/a> from the <code>SalesInfo<\/code> table:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" 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    <span class=\"hljs-keyword\">year<\/span>,\n    <span class=\"hljs-keyword\">month<\/span>,\n    amount\n<span class=\"hljs-keyword\">FROM<\/span>\n    SalesInfo;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><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<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"282\" height=\"335\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Sample-Table.png\" alt=\"SQLite Window Frame - Sample Table\" class=\"wp-image-1809\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Sample-Table.png 282w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Sample-Table-253x300.png 253w\" sizes=\"auto, (max-width: 282px) 100vw, 282px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">1) Using SQLite window frame to calculate running total example<\/h3>\n\n\n\n<p>The following statement uses the <code>SUM()<\/code> window function to calculate the running total of sales by month:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" 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    <span class=\"hljs-keyword\">month<\/span>,\n    amount,\n    <span class=\"hljs-keyword\">SUM<\/span>(amount) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> <span class=\"hljs-keyword\">month<\/span>\n    ) RunningTotal\n<span class=\"hljs-keyword\">FROM<\/span>\n    SalesInfo;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><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<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"310\" height=\"337\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Calculate-Running-Total.png\" alt=\"SQLite Window Frame - Calculate Running Total\" class=\"wp-image-1811\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Calculate-Running-Total.png 310w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Calculate-Running-Total-276x300.png 276w\" sizes=\"auto, (max-width: 310px) 100vw, 310px\" \/><\/figure>\n\n\n\n<p>As mentioned earlier, the <code>SUM()<\/code> window function uses the following window frame options:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><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 means that for the current row, the <code>SUM()<\/code> function will add values from the first row to the current row to calculate the sum.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2) Using SQLite window frame to calculate moving average example<\/h3>\n\n\n\n<p>The following statement uses the <code>AVG()<\/code> window function to calculate the sales moving average:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" 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    <span class=\"hljs-keyword\">month<\/span>,\n    amount,\n    <span class=\"hljs-keyword\">AVG<\/span>(amount) <span class=\"hljs-keyword\">OVER<\/span> (\n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> <span class=\"hljs-keyword\">month<\/span>\n        <span class=\"hljs-keyword\">ROWS<\/span> <span class=\"hljs-keyword\">BETWEEN<\/span> <span class=\"hljs-number\">1<\/span> <span class=\"hljs-keyword\">PRECEDING<\/span> <span class=\"hljs-keyword\">AND<\/span> <span class=\"hljs-number\">1<\/span> <span class=\"hljs-keyword\">FOLLOWING<\/span>\n    ) SalesMovingAverage\n<span class=\"hljs-keyword\">FROM<\/span>\n    SalesInfo;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><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<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"362\" height=\"337\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Calculate-Moving-Average.png\" alt=\"\" class=\"wp-image-1812\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Calculate-Moving-Average.png 362w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Calculate-Moving-Average-300x279.png 300w\" sizes=\"auto, (max-width: 362px) 100vw, 362px\" \/><\/figure>\n\n\n\n<p>In this example, we used the window frame that has three rows: the current row, one row before, and one row after the current row. The <code>AVG()<\/code> used the values of these three rows to calculate the moving average.<\/p>\n\n\n\n<p>You can use the output result set to make a visualization as shown in the following chart:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"282\" src=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Sales-Moving-Average-Chart.png\" alt=\"SQLite Window Frame - Sales Moving Average Chart\" class=\"wp-image-1813\" srcset=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Sales-Moving-Average-Chart.png 470w, https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/SQLite-Window-Frame-Sales-Moving-Average-Chart-300x180.png 300w\" sizes=\"auto, (max-width: 470px) 100vw, 470px\" \/><\/figure>\n\n\n\n<p>Note that a moving average is often used with time series data such as sales to smooth out short-term fluctuations and highlight longer-term sales trends.<\/p>\n\n\n\n<p>In this tutorial, you have learned about the SQLite window frame to specify a subset of partitions for calculation.<\/p>\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=\"1761\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\"\n\t\t\t\tdata-post-title=\"SQLite Window Frame\"\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=\"1761\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\"\n\t\t\t\tdata-post-title=\"SQLite Window Frame\"\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 explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1659,"menu_order":11,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1761","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>SQLite Window Frame in Window Functions<\/title>\n<meta name=\"description\" content=\"This tutorial explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.\" \/>\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.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQLite Window Frame in Window Functions\" \/>\n<meta property=\"og:description\" content=\"This tutorial explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\" \/>\n<meta property=\"og:site_name\" content=\"SQLite Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-16T03:24:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.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\":\"Article\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427\"},\"headline\":\"SQLite Window Frame\",\"datePublished\":\"2018-11-18T10:01:55+00:00\",\"dateModified\":\"2024-04-16T03:24:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\"},\"wordCount\":446,\"image\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png\",\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\",\"url\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\",\"name\":\"SQLite Window Frame in Window Functions\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png\",\"datePublished\":\"2018-11-18T10:01:55+00:00\",\"dateModified\":\"2024-04-16T03:24:37+00:00\",\"description\":\"This tutorial explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage\",\"url\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png\",\"contentUrl\":\"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png\",\"width\":579,\"height\":408},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlitetutorial.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQLite Window Functions\",\"item\":\"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQLite Window Frame\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/#website\",\"url\":\"https:\/\/www.sqlitetutorial.net\/\",\"name\":\"SQLite Tutorial\",\"description\":\"A Step-by-step SQLite Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlitetutorial.net\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427\",\"name\":\"admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQLite Window Frame in Window Functions","description":"This tutorial explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.","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.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/","og_locale":"en_US","og_type":"article","og_title":"SQLite Window Frame in Window Functions","og_description":"This tutorial explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.","og_url":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/","og_site_name":"SQLite Tutorial","article_modified_time":"2024-04-16T03:24:37+00:00","og_image":[{"url":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#article","isPartOf":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/"},"author":{"name":"admin","@id":"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427"},"headline":"SQLite Window Frame","datePublished":"2018-11-18T10:01:55+00:00","dateModified":"2024-04-16T03:24:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/"},"wordCount":446,"image":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png","inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/","url":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/","name":"SQLite Window Frame in Window Functions","isPartOf":{"@id":"https:\/\/www.sqlitetutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png","datePublished":"2018-11-18T10:01:55+00:00","dateModified":"2024-04-16T03:24:37+00:00","description":"This tutorial explains the SQLite window frame and shows you how to use it to specify a subset of partition for calculation.","breadcrumb":{"@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#primaryimage","url":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png","contentUrl":"https:\/\/www.sqlitetutorial.net\/wp-content\/uploads\/2019\/05\/sqlite-window-frame.png","width":579,"height":408},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/sqlite-window-frame\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlitetutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQLite Window Functions","item":"https:\/\/www.sqlitetutorial.net\/sqlite-window-functions\/"},{"@type":"ListItem","position":3,"name":"SQLite Window Frame"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlitetutorial.net\/#website","url":"https:\/\/www.sqlitetutorial.net\/","name":"SQLite Tutorial","description":"A Step-by-step SQLite Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlitetutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlitetutorial.net\/#\/schema\/person\/6d69b968cad0102e30d6694ed8dc6427","name":"admin"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/1761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/comments?post=1761"}],"version-history":[{"count":2,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/1761\/revisions"}],"predecessor-version":[{"id":3196,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/1761\/revisions\/3196"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/pages\/1659"}],"wp:attachment":[{"href":"https:\/\/www.sqlitetutorial.net\/wp-json\/wp\/v2\/media?parent=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}