{"id":7534,"date":"2019-08-12T22:56:36","date_gmt":"2019-08-13T05:56:36","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=7534"},"modified":"2025-06-13T19:27:40","modified_gmt":"2025-06-14T02:27:40","slug":"window-functions-in-couchbase-analytics","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/","title":{"rendered":"Window functions in Couchbase Analytics"},"content":{"rendered":"<p style=\"text-align: center\"><strong>Co-author:\u00a0 Till Westmann,\u00a0 Senior Director, Engineering<\/strong><\/p>\n<hr \/>\n<p><span style=\"font-weight: 400\">The <\/span><a href=\"https:\/\/www.couchbase.com\/downloads?family=server&amp;product=couchbase-server-developer\"><span style=\"font-weight: 400\">bits<\/span><\/a><span style=\"font-weight: 400\"> for Couchbase 6.5, the upcoming release of Couchbase Server, are now available. The Analytics service, which supports efficient parallel query processing, has added support for support for window functions defined in the <a class=\"dd bt mm mn mo mp\" href=\"https:\/\/en.wikipedia.org\/wiki\/Select_(SQL)#Window_function\">sql:2003 standard<\/a>.<\/span><\/p>\n<p><span style=\"font-weight: 400\">For many of us (yours truly included) window functions is this magical feature that we rarely use. But window functions make SQL queries more concise thereby improving readability which makes it easy to maintain queries for real world applications. The queries expressed by window functions would otherwise involve expensive self-joins and subqueries which are hard to optimize resulting in slow running queries. <\/span><span style=\"font-weight: 400\">I\u2019ll illustrate the point by calculating a running total which is the most practical example for using window functions.There are multiple ways of calculating a running total in SQL. In this blog post, I will calculate the running total in two ways &#8211; the old school way using an INNER JOIN and the newly available Window Functions in Couchbase 6.5.<\/span><\/p>\n<h3><b>What is a Running Total?<\/b><\/h3>\n<p><span style=\"font-weight: 400\">A<\/span><a href=\"https:\/\/en.wikipedia.org\/wiki\/Running_total\"> <span style=\"font-weight: 400\">Running Total<\/span><\/a><span style=\"font-weight: 400\"> is a total that is continually adjusted to take account of items as they are added. Another term for it is partial sum. In the example below, the running total for a transaction date would be the InvoiceID\u2019s running total plus the current TransactionAmount.<\/span><\/p>\n<p><span style=\"font-weight: 400\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-7535 size-full\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2019\/08\/image1.png\" alt=\"\" width=\"1830\" height=\"1004\" srcset=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1.png 1830w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1-300x165.png 300w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1-1024x562.png 1024w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1-768x421.png 768w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1-1536x843.png 1536w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1-20x11.png 20w, https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1-1320x724.png 1320w\" sizes=\"auto, (max-width: 1830px) 100vw, 1830px\" \/><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400\">While I have the RunningTotal calculated above, please note the first three fields are the source data and the RunningTotal needs to be calculated using a SQL query.<\/span><\/p>\n<h3><b>Pre-requisites<\/b><\/h3>\n<p><span style=\"font-weight: 400\">Download<\/span><a href=\"https:\/\/www.couchbase.com\/downloads?family=server&amp;product=couchbase-server-developer\"> <span style=\"font-weight: 400\">Couchbase Server 6.5<\/span><\/a><span style=\"font-weight: 400\"> and setup a Couchbase bucket for the sample data to run the queries in this blog post.\u00a0\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">Create a Couchbase bucket called \u201cinvoices\u201d with the data below.<\/span><\/p>\n<pre class=\"lang:default decode:true\">[\r\n  {\r\n    \"invoices\": {\r\n      \"InvoiceID\": 1,\r\n      \"TransactionDate\": \"2019-08-11\",\r\n      \"TransactionAmount\": 100\r\n    }\r\n  },\r\n  {\r\n    \"invoices\": {\r\n      \"InvoiceID\": 2,\r\n      \"TransactionDate\": \"2019-08-11\",\r\n      \"TransactionAmount\": 200\r\n    }\r\n  },\r\n ...\r\n ...\r\n  {\r\n    \"invoices\": {\r\n      \"InvoiceID\": 3,\r\n      \"TransactionDate\": \"2019-08-11\",\r\n      \"TransactionAmount\": 800\r\n    }\r\n  }\r\n]\r\n<\/pre>\n<p><span style=\"font-weight: 400\">On the Analytics workbench, run the following statement to create the dataset<\/span><\/p>\n<pre class=\"lang:default decode:true \">CREATE DATASET invoices on invoices;\r\nCONNECT LINK Local;<\/pre>\n<h3><b>Inner Join query for Running total on a given day<\/b><\/h3>\n<p><span style=\"font-weight: 400\">For each InvoiceID, we need to retrieve the transaction amount and all transaction amounts before it. This is accomplished using an Inner Join with a condition to get each invoice and those prior to it.<\/span><\/p>\n<pre class=\"lang:default decode:true\">SELECT   inv1.InvoiceID , inv1.TransactionDate, inv1.TransactionAmount, SUM(inv2.TransactionAmount) AS RunningTotal\r\nFROM     invoices inv1 JOIN invoices inv2 ON inv1.InvoiceID &gt;= inv2.InvoiceID\r\nWHERE    inv1.TransactionDate = \"2019-08-11\"\r\nGROUP BY inv1.InvoiceID,  inv1.TransactionDate, inv1.TransactionAmount\r\nORDER BY inv1.InvoiceID<\/pre>\n<p><span style=\"font-weight: 400\">JOINS and NoSQL haven\u2019t always played well together. In fact, the conventional wisdom is that data in the NoSQL world is denormalized to avoid JOINs. But Couchbase Analytics was created for data exploration and ad-hoc analysis that includes complex joins and aggregations. The Analytics query engine can process JOINs that are not supported by other NoSQL vendors &#8211;\u00a0<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400\"> \u00a0 \u00a0 <\/span><span style=\"font-weight: 400\">Cassandra \u2013 <\/span><a href=\"https:\/\/cassandra.apache.org\/doc\/latest\/cql\/index.html\"><span style=\"font-weight: 400\">no JOIN support<\/span><span style=\"font-weight: 400\"> in CQL<\/span><\/a><\/li>\n<li><span style=\"font-weight: 400\"> \u00a0 \u00a0 <\/span><span style=\"font-weight: 400\">MongoDB \u2013<\/span><a href=\"https:\/\/docs.mongodb.com\/manual\/reference\/operator\/aggregation\/lookup\/\"> <span style=\"font-weight: 400\">can\u2019t JOIN sharded collections<\/span><\/a><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">In case you are wondering how Couchbase Analytics can join JSON data, I recommend getting under the hood in this<\/span><a href=\"https:\/\/www.youtube.com\/watch?v=1dN11TUj58c\"> <span style=\"font-weight: 400\">video presentation<\/span><\/a><span style=\"font-weight: 400\"> with Prof Mike Carey, <\/span><span style=\"font-weight: 400\">Consulting Chief Architect for<\/span><span style=\"font-weight: 400\"> Couchbase.<\/span><span style=\"font-weight: 400\">\u00a0<\/span><\/p>\n<h3><b>Window function query for Running total on a given day<\/b><\/h3>\n<p><span style=\"font-weight: 400\">If you are not familiar with window functions, I would recommend reading<\/span><a href=\"https:\/\/www.postgresql.org\/docs\/11\/tutorial-window.html\"> <span style=\"font-weight: 400\">PostgresSQL\u2019s documentation<\/span><\/a><span style=\"font-weight: 400\"> which provides a great introduction:\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400\">\u201cA <\/span><i><span style=\"font-weight: 400\">window function<\/span><\/i><span style=\"font-weight: 400\"> performs a calculation across a set of table rows that are somehow related to the current row. This is comparable to the type of calculation that can be done with an aggregate function. But unlike regular aggregate functions, use of a window function does not cause rows to become grouped into a single output row \u2014 the rows retain their separate identities. Behind the scenes, the window function is able to access more than just the current row of the query result.\u201d<\/span><\/p>\n<p><span style=\"font-weight: 400\">Here is what the actual query looks like &#8211;<\/span><\/p>\n<pre class=\"lang:default decode:true\">SELECT   InvoiceID, TransactionDate, TransactionAmount, SUM(TransactionAmount) OVER (ORDER BY InvoiceID) as RunningTotal\r\nFROM     invoices\r\nWHERE    TransactionDate = \"2019-08-11\"\r\nORDER BY InvoiceID\r\n<\/pre>\n<p><span style=\"font-weight: 400\">In addition to the simplicity and conciseness, there are a couple of interesting things about the above statement \u2013<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400\"> \u00a0 \u00a0 <\/span><span style=\"font-weight: 400\">There is an aggregate function but no group by clause. Typically aggregate functions require a group by clause but since we are using the OVER clause, SUM is considered a window function.<\/span><\/li>\n<li><span style=\"font-weight: 400\"> \u00a0 \u00a0 <\/span><span style=\"font-weight: 400\">The OVER clause retrieves a specific set of rows, relative to the current row, and perform an operation over a specific field.<\/span><\/li>\n<li><span style=\"font-weight: 400\"> \u00a0 \u00a0 <\/span><span style=\"font-weight: 400\">ORDER BY defines the logical order in which the window function is evaluated.<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400\">Note:<\/span><span style=\"font-weight: 400\"> Couchbase supports window functions for both the Query and Analytics services and the same query can be run in both the query and the analytics workbenches. To run on the query service, the following indexes need to be created<\/span><\/p>\n<pre class=\"lang:default decode:true\">CREATE PRIMARY INDEX ON invoices;\r\nCREATE INDEX invoices_id ON invoices(InvoiceID);<\/pre>\n<p><span style=\"font-weight: 400\">The purpose of this blog post was to introduce window functions in Couchbase Analytics. Window functions are NOT new to SQL, they are a part of the SQL standard and are available in all major relational databases and Big Data tools like Hive and Spark. With the 6.5 release, Couchbase is bringing these to document databases. If you\u2019d like to experience this first hand \u2013 please <\/span><a href=\"https:\/\/www.couchbase.com\/downloads\/\"><span style=\"font-weight: 400\">download the bits<\/span><\/a><span style=\"font-weight: 400\"> and engage with us on<\/span><a href=\"https:\/\/www.couchbase.com\/forums\/c\/analytics\/\"> <span style=\"font-weight: 400\">forums<\/span><\/a><span style=\"font-weight: 400\">.<\/span><\/p>\n<h3>Resources<b><\/b><\/h3>\n<p><a href=\"https:\/\/docs.couchbase.com\/server\/6.5\/introduction\/whats-new.html\"><span style=\"font-weight: 400\">Couchbase Server 6.5 What\u2019s New<\/span><\/a><\/p>\n<p><a href=\"https:\/\/www.couchbase.com\/blog\/tag\/6-5\/\"><b>All 6.5 Blogs<\/b><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Co-author:\u00a0 Till Westmann,\u00a0 Senior Director, Engineering The bits for Couchbase 6.5, the upcoming release of Couchbase Server, are now available. The Analytics service, which supports efficient parallel query processing, has added support for support for window functions defined in the [&hellip;]<\/p>\n","protected":false},"author":559,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[2294,1821,1816,1812],"tags":[2378,1886,1309,1725],"ppma_author":[9052],"class_list":["post-7534","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","category-couchbase-architecture","category-couchbase-server","category-n1ql-query","tag-6-5","tag-cassandra","tag-mongodb","tag-nosql-database"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.7.1 (Yoast SEO v25.7) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Window functions in Couchbase Analytics - The Couchbase Blog<\/title>\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.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Window functions in Couchbase Analytics\" \/>\n<meta property=\"og:description\" content=\"Co-author:\u00a0 Till Westmann,\u00a0 Senior Director, Engineering The bits for Couchbase 6.5, the upcoming release of Couchbase Server, are now available. The Analytics service, which supports efficient parallel query processing, has added support for support for window functions defined in the [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-13T05:56:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T02:27:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1830\" \/>\n\t<meta property=\"og:image:height\" content=\"1004\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sachin Smotra, Director Product Management, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@smotras\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sachin Smotra, Director Product Management, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\"},\"author\":{\"name\":\"Sachin Smotra, Director Product Management, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b0afdfaea6775eaf75096b65e7791f9a\"},\"headline\":\"Window functions in Couchbase Analytics\",\"datePublished\":\"2019-08-13T05:56:36+00:00\",\"dateModified\":\"2025-06-14T02:27:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\"},\"wordCount\":771,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"keywords\":[\"6.5\",\"cassandra\",\"mongodb\",\"NoSQL Database\"],\"articleSection\":[\"Couchbase Analytics\",\"Couchbase Architecture\",\"Couchbase Server\",\"SQL++ \/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\",\"name\":\"Window functions in Couchbase Analytics - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2019-08-13T05:56:36+00:00\",\"dateModified\":\"2025-06-14T02:27:40+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Window functions in Couchbase Analytics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b0afdfaea6775eaf75096b65e7791f9a\",\"name\":\"Sachin Smotra, Director Product Management, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/e0fd86aac479bbde276340e2945bbd5c\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/351d2ab52ac22b2cfdfc83ff4a2dc0b377d8316ecb298656b8c1a5f9e70a141b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/351d2ab52ac22b2cfdfc83ff4a2dc0b377d8316ecb298656b8c1a5f9e70a141b?s=96&d=mm&r=g\",\"caption\":\"Sachin Smotra, Director Product Management, Couchbase\"},\"description\":\"Sachin Smotra\u2019s career spans more than 15 years building software products across various domains including Java Enterprise software, DRM Solutions for mobile games and web conferencing. As Director Product Management at Couchbase, he is a hands-on product leader responsible for Couchbase Mobile, IOT and Analytics product lines including evangelizing the product strategy and vision with customers, partners, developers and analysts. Before joining Couchbase, Sachin was a Senior Manager, Product Management, at Cisco WebEx where he led the product team responsible for transforming the end to end Customer Experience across the WebEx product lifecycle - consideration, purchase, usage and renewals. Prior to his time at Cisco, Sachin worked at different startups in a multitude of roles across engineering, architecture, product management and alliances.\",\"sameAs\":[\"https:\/\/x.com\/smotras\"],\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/ssmotra\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Window functions in Couchbase Analytics - The Couchbase Blog","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.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/","og_locale":"en_US","og_type":"article","og_title":"Window functions in Couchbase Analytics","og_description":"Co-author:\u00a0 Till Westmann,\u00a0 Senior Director, Engineering The bits for Couchbase 6.5, the upcoming release of Couchbase Server, are now available. The Analytics service, which supports efficient parallel query processing, has added support for support for window functions defined in the [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/","og_site_name":"The Couchbase Blog","article_published_time":"2019-08-13T05:56:36+00:00","article_modified_time":"2025-06-14T02:27:40+00:00","og_image":[{"width":1830,"height":1004,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2019\/08\/image1.png","type":"image\/png"}],"author":"Sachin Smotra, Director Product Management, Couchbase","twitter_card":"summary_large_image","twitter_creator":"@smotras","twitter_misc":{"Written by":"Sachin Smotra, Director Product Management, Couchbase","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/"},"author":{"name":"Sachin Smotra, Director Product Management, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b0afdfaea6775eaf75096b65e7791f9a"},"headline":"Window functions in Couchbase Analytics","datePublished":"2019-08-13T05:56:36+00:00","dateModified":"2025-06-14T02:27:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/"},"wordCount":771,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","keywords":["6.5","cassandra","mongodb","NoSQL Database"],"articleSection":["Couchbase Analytics","Couchbase Architecture","Couchbase Server","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/","url":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/","name":"Window functions in Couchbase Analytics - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2019-08-13T05:56:36+00:00","dateModified":"2025-06-14T02:27:40+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/window-functions-in-couchbase-analytics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Window functions in Couchbase Analytics"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/b0afdfaea6775eaf75096b65e7791f9a","name":"Sachin Smotra, Director Product Management, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/e0fd86aac479bbde276340e2945bbd5c","url":"https:\/\/secure.gravatar.com\/avatar\/351d2ab52ac22b2cfdfc83ff4a2dc0b377d8316ecb298656b8c1a5f9e70a141b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/351d2ab52ac22b2cfdfc83ff4a2dc0b377d8316ecb298656b8c1a5f9e70a141b?s=96&d=mm&r=g","caption":"Sachin Smotra, Director Product Management, Couchbase"},"description":"Sachin Smotra\u2019s career spans more than 15 years building software products across various domains including Java Enterprise software, DRM Solutions for mobile games and web conferencing. As Director Product Management at Couchbase, he is a hands-on product leader responsible for Couchbase Mobile, IOT and Analytics product lines including evangelizing the product strategy and vision with customers, partners, developers and analysts. Before joining Couchbase, Sachin was a Senior Manager, Product Management, at Cisco WebEx where he led the product team responsible for transforming the end to end Customer Experience across the WebEx product lifecycle - consideration, purchase, usage and renewals. Prior to his time at Cisco, Sachin worked at different startups in a multitude of roles across engineering, architecture, product management and alliances.","sameAs":["https:\/\/x.com\/smotras"],"url":"https:\/\/www.couchbase.com\/blog\/author\/ssmotra\/"}]}},"authors":[{"term_id":9052,"user_id":559,"is_guest":0,"slug":"ssmotra","display_name":"Sachin Smotra, Director Product Management, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/351d2ab52ac22b2cfdfc83ff4a2dc0b377d8316ecb298656b8c1a5f9e70a141b?s=96&d=mm&r=g","author_category":"","last_name":"Smotra, Director Product Management, Couchbase","first_name":"Sachin","job_title":"","user_url":"","description":"Sachin Smotra\u2019s career spans more than 15 years building software products across various domains including Java Enterprise software, DRM Solutions for mobile games and web conferencing. As Director Product Management at Couchbase, he is a hands-on product leader responsible for Couchbase Mobile, IOT and Analytics product lines including evangelizing the product strategy and vision with customers, partners, developers and analysts.\r\n\r\nBefore joining Couchbase, Sachin was a Senior Manager, Product Management, at Cisco WebEx where he led the product team responsible for transforming the end to end Customer Experience across the WebEx product lifecycle - consideration, purchase, usage and renewals. Prior to his time at Cisco, Sachin worked at different startups in a multitude of roles across engineering, architecture, product management and alliances."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/7534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/559"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=7534"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/7534\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=7534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=7534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=7534"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=7534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}