{"id":6995,"date":"2023-05-18T00:00:00","date_gmt":"2023-05-18T04:00:00","guid":{"rendered":"https:\/\/www.sisense.com\/how-to-calculate-cohort-retention-in-sql\/"},"modified":"2024-10-31T21:31:06","modified_gmt":"2024-11-01T01:31:06","slug":"how-to-calculate-cohort-retention-in-sql","status":"publish","type":"post","link":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/","title":{"rendered":"How to calculate cohort retention in SQL"},"content":{"rendered":"<p><\/p>\r\n<p><em>SQL is one of the analyst\u2019s most powerful tools. In\u00a0<strong>SQL Superstar<\/strong>, we give you actionable advice to help you get the most out of this versatile language and create beautiful, effective queries.<\/em><\/p>\r\n<p>Losing users sucks. Losing customers really sucks. If you\u2019re a startup, you know that <a href=\"https:\/\/andrewchen.co\/retention-is-king\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Retention is King<\/a>. You should always be measuring and improving your user retention, so you can keep more users over time. In this post, we\u2019ll show you how to calculate <a href=\"\/blog\/how-to-calculate-cohort-retention-in-sql\/\">user retention on your own data in SQL<\/a>.<\/p>\r\n<h2>Defining retention<\/h2>\r\n<p>If Gloria used the product on Monday and used the product again on Tuesday, she is a retained user. If Bill used the product on Monday, but not on Tuesday, he is a lapsed user. Retention for Monday is the number of retained users divided by the number of total users. If Gloria and Bill were the only two users on Monday, then retention for Monday is 50%.<\/p>\r\n<h2>Calculating basic user retention<\/h2>\r\n<p>The key to calculating retention is counting users who were active at time #1, then counting how many were active at time #2. An easy way to do this in SQL is to left join your user activity table to itself like so:<\/p>\r\n<pre class=\"wp-block-code\"><code>select *\r\nfrom activity\r\nleft join activity as future_activity on\r\n  activity.user_id = future_activity.user_id\r\n  and activity.date = future_activity.date - interval '1 day'<\/code><\/pre>\r\n<p>Now, for every row of user activity, we have \u2014 in that same row \u2014 their activity 1 day in the future. This gives us an ideal table for calculating retention with some simple counts:<\/p>\r\n<pre class=\"wp-block-code\"><code>select\r\n  activity.date, \r\n  count(distinct activity.user_id) as active_users, \r\n  count(distinct future_activity.user_id) as retained_users,\r\n  count(distinct future_activity.user_id) \/ \r\n    count(distinct activity.user_id)::float as retention\r\nfrom activity\r\nleft join activity as future_activity on\r\n  activity.user_id = future_activity.user_id\r\n  and activity.date = future_activity.date - interval '1 day'\r\ngroup by 1<\/code><\/pre>\r\n<p>We get this chart:<\/p>\r\n<figure class=\"wp-block-image fancybox\"><img decoding=\"async\" class=\"wp-image-75927\" src=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/active-user-retention.png\" alt=\"Active user retention chart\" \/><\/figure>\r\n<p>For extra credit, change the 1-day retention to 7-day or 30-day to capture a sense of longer-term user engagement.<\/p>\r\n<h2>Calculating retention of new vs. existing users<\/h2>\r\n<p>Often retention is quite different for users who just signed up compared to loyal long-term users. To calculate new user retention, simply join in your users table and only look at activity rows that occurred on the user\u2019s join date:<\/p>\r\n<pre class=\"wp-block-code\"><code>select\r\n  users.date as date,\r\n  count(distinct activity.user_id) as new_users, \r\n  count(distinct future_activity.user_id) as retained_users,\r\n  count(distinct future_activity.user_id) \/ \r\n    count(distinct activity.user_id)::float as retention\r\nfrom activity\r\n-- Limits activity to activity from new users\r\njoin users on\r\n  activity.user_id = users.id \r\n  and users.date = activity.date\r\nleft join activity as future_activity on\r\n  activity.user_id = future_activity.user_id\r\n  and activity.date = future_activity.date - interval '1 day'\r\ngroup by 1<\/code><\/pre>\r\n<figure class=\"wp-block-image fancybox\"><img decoding=\"async\" class=\"wp-image-75932\" src=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/New-user-retention-1.png\" alt=\"New user retention chart\" \/><\/figure>\r\n<p>We see that while overall retention is 46%, new user retention is only 5.8%! Now we see why it\u2019s so useful to split out new users. Improving new user retention should clearly be a priority.<\/p>\r\n<p>To look at returning user retention, simply change:<\/p>\r\n<pre class=\"wp-block-code\"><code>users.date = activity.date <\/code><\/pre>\r\n<p>to:<\/p>\r\n<pre class=\"wp-block-code\"><code>users.date != activity.date<\/code><\/pre>\r\n<p>This effectively excludes activity from users who joined that day. Our query now looks like:<\/p>\r\n<pre class=\"wp-block-code\"><code>select\r\n  activity.date as date,\r\n  count(distinct activity.user_id) as new_users, \r\n  count(distinct future_activity.user_id) as retained_users,\r\n  count(distinct future_activity.user_id) \/ \r\n    count(distinct activity.user_id)::float as retention\r\nfrom activity\r\n-- Limits activity to activity from existing users\r\njoin users on \r\n  activity.user_id = users.id \r\n  and users.date != activity.date\r\nleft join activity as future_activity on\r\n  activity.user_id = future_activity.user_id\r\n  and activity.date = future_activity.date - interval '1 day'\r\ngroup by 1<\/code><\/pre>\r\n<figure class=\"wp-block-image fancybox\"><img decoding=\"async\" class=\"wp-image-75969\" src=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/Existing-user-retention.png\" alt=\"Existing user retention\" \/><\/figure>\r\n<p>As expected, existing user retention is higher than the overall average: 66% vs. 46%.<\/p>\r\n<h2>Calculating retention in cohorts<\/h2>\r\n<p>It can be very helpful to compare the retention of users who joined in week A with those who joined in week B. This lets us see if our product changes are improving our retention rate. Ideally we\u2019d end up with a chart like this:<\/p>\r\n<figure class=\"wp-block-image fancybox\"><img decoding=\"async\" class=\"wp-image-75942\" src=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/By-cohort.png\" alt=\"By cohort\" \/><\/figure>\r\n<p>We\u2019ll start by defining a few handy subqueries to simplify the problem: new_user_activity restricts user activity to new users:<\/p>\r\n<pre class=\"wp-block-code\"><code>with new_user_activity as (\r\n  select activity.* from activity\r\n  join users on\r\n    users.id = activity.user_id\r\n    and users.date = activity.date\r\n)<\/code><\/pre>\r\n<p>Cohort_active_user_count calculates the total number of active users \u2014 the denominator in our retention calculation \u2014 in each daily cohort:<\/p>\r\n<pre class=\"wp-block-code\"><code>, cohort_active_user_count as (\r\n  select \r\n    date, count(distinct user_id) as count \r\n  from new_user_activity\r\n  group by 1\r\n)<\/code><\/pre>\r\n<p>On top of that, we\u2019ll make a few smaller changes to the main query:<\/p>\r\n<p>Calculate the retention period \u2014 the number days retained \u2014 as future_activity.date &#8211; new_user_activity.date and group by it. With this grouping, we lose the simple count of active users in the cohort. Fortunately, we thought of this and made our Cohort_active_user_count subquery, which we can join in and use as the denominator.<\/p>\r\n<p>Finally, we\u2019ll wrap the query in an outer query that makes nice looking output, excludes bogus rows, and sorts.<\/p>\r\n<p>Without further ado:<\/p>\r\n<pre class=\"wp-block-code\"><code>select date, 'Day '|| to_char(period, 'DD') as period,\r\n  new_users, retained_users, retention \r\nfrom (\r\n  select \r\n    new_user_activity.date as date,\r\n    (future_activity.date \r\n      - new_user_activity.date) as period,\r\n    max(cohort_size.count) as new_users, -- all equal in group\r\n    count(distinct future_activity.user_id) as retained_users,\r\n    count(distinct future_activity.user_id) \/ \r\n      max(cohort_size.count)::float as retention\r\n  from new_user_activity\r\n  left join activity as future_activity on\r\n    new_user_activity.user_id = future_activity.user_id\r\n    and new_user_activity.date = future_activity.date\r\n  left join cohort_active_user_count as cohort_size on \r\n    new_user_activity.date = cohort_size.date \r\n  group by 1, 2) t\r\nwhere period is not null\r\norder by date, period<\/code><\/pre>\r\n<p>Notice also the range join, one of our favorite SQL tricks, to get multiple days of retention in one chart.<\/p>\r\n<p>This results in the table:<\/p>\r\n<figure class=\"wp-block-image fancybox\"><img decoding=\"async\" class=\"wp-image-75947\" src=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/Retention-by-Cohort-table.png\" alt=\"New User Retention by Cohort\" \/><\/figure>\r\n<p>With Sisense for Cloud Data Teams, we can automatically pivot the result then color by percentile:<\/p>\r\n<figure class=\"wp-block-image fancybox\"><img decoding=\"async\" class=\"wp-image-75952\" src=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/By-cohort-blue.png\" alt=\"New User Retention by Cohort blue chart\" \/><\/figure>\r\n<h2>Making retention more specific<\/h2>\r\n<p>Remember how different new user and existing user retention were? You can see the same variations across lots of user segments. It\u2019s worth breaking out retention by: demographics, user acquisition channel, paying vs. non-paying users, or different kinds of activity \u2014 viewing, creating, buying, etc.<\/p>\r\n<p><em>David Ganzhorn found his passion for data analysis while at Google on the Ads Quality team, then worked at Periscope Data for 6 years before becoming part of Sisense. His projects have spanned data science, data engineering, and product engineering, including working on the R and Python cloud editor, predictive lead scoring models for sales, and full-stack software performance optimization. When he&#8217;s not helping change the world of analytics, David enjoys crafting educational software for his child.<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>SQL is one of the analyst\u2019s most powerful tools. In\u00a0SQL Superstar, we give you actionable advice to help you get the most out of this versatile language and create beautiful, effective queries. Losing users sucks. Losing customers really sucks. If&#8230;<\/p>\n","protected":false},"author":4,"featured_media":7197,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_searchwp_excluded":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[44],"tags":[472],"application":[46,10],"buyer-role":[],"buyer-stage":[],"department":[],"industry":[],"topic":[73],"class_list":["post-6995","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech-talk","tag-data-team","application-bi-analytics-teams","application-cloud-data-teams","topic-sql-superstar"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v23.5 (Yoast SEO v23.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Calculate Cohort Retention in SQL | Sisense<\/title>\n<meta name=\"description\" content=\"Losing users sucks. In this post, we\u2019ll show you how to calculate user retention on your own data in SQL so you can keep more users over time.\" \/>\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.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to calculate cohort retention in SQL\" \/>\n<meta property=\"og:description\" content=\"SQL is one of the analyst\u2019s most powerful tools. In\u00a0SQL Superstar, we give you actionable advice to help you get the most out of this versatile language\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\" \/>\n<meta property=\"og:site_name\" content=\"Sisense\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-18T04:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T01:31:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/pd-blog-yoast-how-to-calculate-cohort-retention-in-sql-min.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sisense Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/pd-blog-yoast-how-to-calculate-cohort-retention-in-sql-min.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@sisense\" \/>\n<meta name=\"twitter:site\" content=\"@sisense\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sisense Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\"},\"author\":{\"name\":\"Sisense Team\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115\"},\"headline\":\"How to calculate cohort retention in SQL\",\"datePublished\":\"2023-05-18T04:00:00+00:00\",\"dateModified\":\"2024-11-01T01:31:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\"},\"wordCount\":738,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.sisense.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg\",\"keywords\":[\"data team\"],\"articleSection\":[\"Tech Talk\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\",\"url\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\",\"name\":\"How To Calculate Cohort Retention in SQL | Sisense\",\"isPartOf\":{\"@id\":\"https:\/\/www.sisense.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg\",\"datePublished\":\"2023-05-18T04:00:00+00:00\",\"dateModified\":\"2024-11-01T01:31:06+00:00\",\"description\":\"Losing users sucks. In this post, we\u2019ll show you how to calculate user retention on your own data in SQL so you can keep more users over time.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage\",\"url\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg\",\"contentUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg\",\"width\":1200,\"height\":628,\"caption\":\"pd blog featured how to calculate cohort retention in sql min\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sisense.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to calculate cohort retention in SQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sisense.com\/#website\",\"url\":\"https:\/\/www.sisense.com\/\",\"name\":\"Sisense\",\"description\":\"Build your business with anywhere-analytics\",\"publisher\":{\"@id\":\"https:\/\/www.sisense.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sisense.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.sisense.com\/#organization\",\"name\":\"Sisense\",\"url\":\"https:\/\/www.sisense.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg\",\"contentUrl\":\"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg\",\"width\":1200,\"height\":600,\"caption\":\"Sisense\"},\"image\":{\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/sisense\",\"https:\/\/www.linkedin.com\/company\/sisense\",\"https:\/\/github.com\/sisense\/\"],\"description\":\"Sisense accelerates product innovation through AI\/ML capabilities. Our global analytics platform lets customers drive better, faster decisions for their business and end users.\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115\",\"name\":\"Sisense Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sisense.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g\",\"caption\":\"Sisense Team\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How To Calculate Cohort Retention in SQL | Sisense","description":"Losing users sucks. In this post, we\u2019ll show you how to calculate user retention on your own data in SQL so you can keep more users over time.","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.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/","og_locale":"en_US","og_type":"article","og_title":"How to calculate cohort retention in SQL","og_description":"SQL is one of the analyst\u2019s most powerful tools. In\u00a0SQL Superstar, we give you actionable advice to help you get the most out of this versatile language","og_url":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/","og_site_name":"Sisense","article_published_time":"2023-05-18T04:00:00+00:00","article_modified_time":"2024-11-01T01:31:06+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/pd-blog-yoast-how-to-calculate-cohort-retention-in-sql-min.jpg","type":"image\/jpeg"}],"author":"Sisense Team","twitter_card":"summary_large_image","twitter_image":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/pd-blog-yoast-how-to-calculate-cohort-retention-in-sql-min.jpg","twitter_creator":"@sisense","twitter_site":"@sisense","twitter_misc":{"Written by":"Sisense Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#article","isPartOf":{"@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/"},"author":{"name":"Sisense Team","@id":"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115"},"headline":"How to calculate cohort retention in SQL","datePublished":"2023-05-18T04:00:00+00:00","dateModified":"2024-11-01T01:31:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/"},"wordCount":738,"commentCount":0,"publisher":{"@id":"https:\/\/www.sisense.com\/#organization"},"image":{"@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg","keywords":["data team"],"articleSection":["Tech Talk"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/","url":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/","name":"How To Calculate Cohort Retention in SQL | Sisense","isPartOf":{"@id":"https:\/\/www.sisense.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage"},"image":{"@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg","datePublished":"2023-05-18T04:00:00+00:00","dateModified":"2024-11-01T01:31:06+00:00","description":"Losing users sucks. In this post, we\u2019ll show you how to calculate user retention on your own data in SQL so you can keep more users over time.","breadcrumb":{"@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#primaryimage","url":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg","contentUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/2014\/06\/10161630\/pd-blog-featured-how-to-calculate-cohort-retention-in-sql-min.jpg","width":1200,"height":628,"caption":"pd blog featured how to calculate cohort retention in sql min"},{"@type":"BreadcrumbList","@id":"https:\/\/www.sisense.com\/blog\/how-to-calculate-cohort-retention-in-sql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sisense.com\/"},{"@type":"ListItem","position":2,"name":"How to calculate cohort retention in SQL"}]},{"@type":"WebSite","@id":"https:\/\/www.sisense.com\/#website","url":"https:\/\/www.sisense.com\/","name":"Sisense","description":"Build your business with anywhere-analytics","publisher":{"@id":"https:\/\/www.sisense.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sisense.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.sisense.com\/#organization","name":"Sisense","url":"https:\/\/www.sisense.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg","contentUrl":"https:\/\/cdn.sisense.com\/wp-content\/uploads\/sisense-yoast-og.jpg","width":1200,"height":600,"caption":"Sisense"},"image":{"@id":"https:\/\/www.sisense.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/sisense","https:\/\/www.linkedin.com\/company\/sisense","https:\/\/github.com\/sisense\/"],"description":"Sisense accelerates product innovation through AI\/ML capabilities. Our global analytics platform lets customers drive better, faster decisions for their business and end users."},{"@type":"Person","@id":"https:\/\/www.sisense.com\/#\/schema\/person\/e70aa3a7bbc471e4b7b8c5a7d2b36115","name":"Sisense Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sisense.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/213e415f47bc3c7f0155a0755b1cea8c?s=96&d=mm&r=g","caption":"Sisense Team"}}]}},"_links":{"self":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts\/6995"}],"collection":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/comments?post=6995"}],"version-history":[{"count":1,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts\/6995\/revisions"}],"predecessor-version":[{"id":23235,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/posts\/6995\/revisions\/23235"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/media\/7197"}],"wp:attachment":[{"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/media?parent=6995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/categories?post=6995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/tags?post=6995"},{"taxonomy":"application","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/application?post=6995"},{"taxonomy":"buyer-role","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/buyer-role?post=6995"},{"taxonomy":"buyer-stage","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/buyer-stage?post=6995"},{"taxonomy":"department","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/department?post=6995"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/industry?post=6995"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.sisense.com\/wp-json\/wp\/v2\/topic?post=6995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}