<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Data Analysis Journal: SQL]]></title><description><![CDATA[All things SQL - tutorials, interview questions, and solutions ]]></description><link>https://dataanalysis.substack.com/s/sql</link><image><url>https://substackcdn.com/image/fetch/$s_!WdsI!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd7029b3-f274-4215-ac43-d275f496ecf8_200x200.png</url><title>Data Analysis Journal: SQL</title><link>https://dataanalysis.substack.com/s/sql</link></image><generator>Substack</generator><lastBuildDate>Thu, 16 Apr 2026 11:42:06 GMT</lastBuildDate><atom:link href="https://dataanalysis.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Olga Berezovsky]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[dataanalysis@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[dataanalysis@substack.com]]></itunes:email><itunes:name><![CDATA[Olga Berezovsky]]></itunes:name></itunes:owner><itunes:author><![CDATA[Olga Berezovsky]]></itunes:author><googleplay:owner><![CDATA[dataanalysis@substack.com]]></googleplay:owner><googleplay:email><![CDATA[dataanalysis@substack.com]]></googleplay:email><googleplay:author><![CDATA[Olga Berezovsky]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Refresher on SQL for Data Analysis - Issue 238]]></title><description><![CDATA[SQL solutions for data analysis, ad hoc, and modeling.]]></description><link>https://dataanalysis.substack.com/p/refresher-on-sql-for-data-analysis</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/refresher-on-sql-for-data-analysis</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 25 Dec 2024 13:02:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02923186-eef6-47f8-b619-252d09c30dd3_1600x900.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Do you know what's best to do on Christmas morning? Learning SQL.</p><p>One last refresher from me this year, and maybe the most important one - SQL!</p><p>Today, I share a quick refresher on SQL with my solutions for common data analytics projects I had to go through many times over my tenure as an analyst. I hope it will help you advance and save you time. Read below:</p><ul><li><p>SQL for getting blended retention and cohorted retention</p></li><li><p>SQL for ranking the top-used product features</p></li><li><p>SQL for frequency of usage analysis</p></li><li><p>SQL for weekday product usage analysis</p></li><li><p>SQL for getting average logins per user per day</p></li><li><p>SQL for getting adjacent user persona</p></li><li><p>SQL for getting a random set of users for ML and analytics</p></li><li><p>SQL for flattening JSON</p></li><li><p>How to model tables for subscription reporting</p></li><li><p>How to join 2 tables that are not related by a foreign key relationship</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k4h6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k4h6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!k4h6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!k4h6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!k4h6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k4h6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png" width="184" height="184" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:184,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!k4h6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!k4h6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!k4h6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!k4h6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16530b64-1f9b-4dff-af8a-091a855e636b_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><h2>SQL for getting retention and cohorted retention</h2><p>I have about 4-5 different SQL queries for retention, depending on the table structure, the definition of retention, and the product. Most analytics teams end up creating models for retention in a specific format. For example, it&#8217;s common to create an <em>active_user</em> table and assign flags to every user for R(D1), R(D7), R(Day 30), and so on. Having such a consolidated table makes it easy to pull retention data, as you don&#8217;t need to run calculations or use CASE statements in every SQL query to pull retention KPIs. However, it takes time to create these views.</p><p>Here are some of my SQL examples for blended and cohorted retention - <em><a href="https://www.lennysnewsletter.com/p/measuring-cohort-retention">How to measure cohort retention</a></em>.</p><h2>SQL for ranking the top-used product features</h2><p>You can&#8217;t just come in and run a query to get the top-used features out of the blue. You need to have user activity already mapped to the features table, which is not trivial when you are getting activity data from event streams. Translating raw events into defined user actions (e.g., onboarding completion, dashboard usage, logging activity, item browsing, etc.) takes time. On top of that, merging and mapping this data with subscriptions, DAU, or attribution is even harder.</p><p>More often than not, teams simply store user actions (such as cta_click, screen_view, profile_updated, etc.) as a proxy for features. You may have a table with <em>activity_type</em> that includes signup, purchase, login, home_screen_view, profile_updated, and other granularity in the form of raw events and actions users create while using your product. But user <em>activity</em> is not the same as a <em>product feature</em>. Activity may contain clues about which parent features the user clicks and views belong to. If you are less lucky, you will need to map the action data you have to features. In any case, you have to start with getting the higher activity type and then work on mapping them to features.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wnX0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wnX0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wnX0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wnX0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wnX0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wnX0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg" width="1456" height="258" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:258,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wnX0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 424w, https://substackcdn.com/image/fetch/$s_!wnX0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 848w, https://substackcdn.com/image/fetch/$s_!wnX0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!wnX0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01bf19cc-7b5a-4369-ad8c-e2408a72d523_1456x258.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Here is how I do it, along with my SQL solution for getting top-used features - <em><a href="https://dataanalysis.substack.com/p/ranking-the-top-used-product-features">Ranking The Top Used Product Features</a></em>.</p><h2>SQL for user frequency of usage analysis</h2><p>Your product may be intended for episodic use instead of daily (Airbnb, Lyft, Tinder, Dropbox, LinkedIn), so your DAU/MAU ratio could be small regardless of high volume usage, which isn&#8217;t that helpful to illustrate your true user engagement. You are most likely to have a few small groups of power users driving daily usage, while other product personas prevail in bi-weekly or monthly usage.</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/refresher-on-sql-for-data-analysis">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Parsing Semi-Structured Data In SQL - Issue 177]]></title><description><![CDATA[How to process and work with JSON formats via SQL in Snowflake]]></description><link>https://dataanalysis.substack.com/p/parsing-semi-structured-data-in-sql</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/parsing-semi-structured-data-in-sql</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 20 Dec 2023 13:00:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!TDD1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F34e59413-4ca1-4746-965a-5f19652e4c45_1548x348.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Welcome to the <a href="https://dataanalysis.substack.com/">Data Analysis Journal</a>, a weekly newsletter about data science and analytics.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p>
      <p>
          <a href="https://dataanalysis.substack.com/p/parsing-semi-structured-data-in-sql">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[SQL For Weekday Product Usage Analysis - Issue 166]]></title><description><![CDATA[How to get the frequency of user engagement in SQL: day of the week analysis]]></description><link>https://dataanalysis.substack.com/p/sql-for-weekday-product-usage-analysis</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/sql-for-weekday-product-usage-analysis</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 11 Oct 2023 12:00:19 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffd342448-536f-414b-8b4f-fb4cb6615d0b_1720x1088.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Welcome to the <a href="https://dataanalysis.substack.com/">Data Analysis Journal</a>, a weekly data science and analytics newsletter.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><p>Today&#8217;s topic is a SQL solution for one of my favorite quick data explorations - <strong>weekday usage analysis </strong>(also known as DOW analysis - day of the week). </p><p>I often run it as the first query when working on a new dataset or during my onboarding - breaking user actions down by the days of the week.&nbsp;</p><p>It&#8217;s my favorite because it&#8217;s simple to pull, literally takes only a few minutes to write the query, and the data is easy to interpret and present. At the same time, it opens a universe of insight into the business type, lifecycle, and user behavior. It helps to answer questions like:&nbsp;</p><ul><li><p>Does the business/product have weekly cyclicality?&nbsp;</p></li><li><p>If yes, what does it look like? When does the largest volume of activity happen? Is it a complete pattern?&nbsp;</p></li><li><p>What impact do holidays and weekends create?&nbsp;</p></li><li><p>How does user acquisition work?&nbsp;What % of paid traffic drives signups?&nbsp;</p></li></ul><p>Weekday usage analysis provides a segue into exploring user behavior and activity.</p><p>Weekly cyclicality often speaks for the type of business or product offering - do users use the product during weekdays or weekends? Does it change with the beginning/end of the month? When you break users down into profiles or segments, you might notice that some personas use the product the most every Monday or Friday. or, for example, that users who are likely to churn tend to only use the product on weekends. These insights can help optimize product offerings or even affect the A/B test.</p><p>Below, I&#8217;ll share the SQL code and my approach to exploring the activity pattern.</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/sql-for-weekday-product-usage-analysis">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[A Selection Of SQL Tutorials - Issue 163]]></title><description><![CDATA[A roundup of my favorite free SQL tutorials to get started with or advance at querying]]></description><link>https://dataanalysis.substack.com/p/a-selection-of-sql-tutorials-issue-cf9</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/a-selection-of-sql-tutorials-issue-cf9</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 27 Sep 2023 12:02:43 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!q1Aq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome to my<a href="https://dataanalysis.substack.com/"> Data Analytics Journal</a>, where I write about data science and analytics.</p><p>This month, paid subscribers learned about:</p><ul><li><p><a href="https://dataanalysis.substack.com/p/how-to-pass-a-first-round-interview">How to pass a first-round interview for data science roles</a> - tips and suggestions about navigating the interview process specifically for data science and analytics roles. Recommendations on how to stand out from other candidates.</p></li><li><p><a href="https://dataanalysis.substack.com/p/how-strava-accelerated-user-engagement">How Strava Accelerated User Engagement</a> - inside analytics at Strava: its process and tooling. A case study on the Route Detail page redesign that improved user activity in the app.</p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-do-a-root-cause-analysis-issue">How To Do a Root Cause Analysis</a> - my approach and framework for running a root cause analysis to understand unexpected user behavior change or metric decline.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p></li></ul><p>Many years ago, I started making a list of my favorite go-to SQL videos, articles, and lessons I still use today. Every 6 months, I update the list to keep it relevant and add new sources. Below is my refreshed list of mostly free SQL tutorials and practice sites.</p><p>I had to learn SQL at school, but many successful analysts I know are self-taught SQL coders.&nbsp;</p><p>Personally, I wouldn&#8217;t recommend enrolling in bootcamps or expensive programs to learn SQL. Go through the publications and videos below, and I guarantee you will be comfortable within a few months. It&#8217;s all about practice.&nbsp;</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bUJN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bUJN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!bUJN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!bUJN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!bUJN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bUJN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bUJN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!bUJN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!bUJN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!bUJN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F76f2541c-0aea-4c8f-b1af-0709f28a7368_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><h2><strong>&#128756; Getting started</strong></h2><ul><li><p><a href="https://www.sohamkamani.com/blog/2016/07/07/a-beginners-guide-to-sql/">A beginner's guide to SQL</a> - a little old, but still one of the best introductions I&#8217;ve seen.&nbsp;</p></li><li><p><a href="https://thoughtbot.com/blog/understanding-sql-join">Understanding SQL Join</a></p></li><li><p><a href="https://vladmihalcea.com/sql-left-join/">SQL LEFT JOIN &#8211; A Beginner&#8217;s Guide</a> - a really good read from one of the engineering champions <a href="https://vladmihalcea.com/">Vlad Mihalcea</a>. I was a fan of his writing before he journeyed from data to Java. His evergreen LEFT JOIN guide still stays my favorite</p></li><li><p><a href="https://www.pluralsight.com/guides/using-on-versus-where-clauses-to-combine-and-filter-data-in-postgresql-joins">Using ON Versus WHERE Clauses to Combine and Filter Data in PostgreSQL Joins</a> - this is one of the common interview questions for analysts.</p></li><li><p><a href="https://codingsight.com/learn-database-design-with-sql-server-management-studio/">Learn Database Design with SQL Server</a> - walks you through how to install a database, its terminology, fundamental concepts, usage, etc. Their walkthrough can be applied to other SQL variations besides SQL Server. If you are a MySQL user, here is a similar one - a <a href="https://www.mysqltutorial.org/">MySQL tutorial</a>.</p></li><li><p>One and only <a href="https://www.sqlstyle.guide/">A SQL Style Guide</a>.</p></li></ul><h2><strong>&#128690; Become proficient</strong></h2><ul><li><p><a href="https://towardsdatascience.com/take-your-sql-skills-to-the-next-level-by-understanding-the-self-join-75f1d52f2322">Understanding The Self Join</a></p></li><li><p><a href="https://www.metabase.com/learn/sql-questions/sql-best-practices">Best practices for writing SQL queries</a></p></li><li><p><a href="https://365datascience.com/tutorials/sql-tutorials/sql-best-practices/">SQL Best Practices - How to type code cleanly and perfectly organized</a></p></li><li><p><a href="https://towardsdatascience.com/top-5-sql-analytic-functions-every-data-analyst-needs-to-know-3f32788e4ebb">Top 5 SQL Analytic Functions Every Data Analyst Needs to Know</a></p></li><li><p><a href="https://coffingdw.com/snowflake-analytics-part-7-lag/">Snowflake Analytics &#8211; Lag</a></p></li><li><p><a href="https://fivetran.com/blog/bucketing-in-sql">Bucketing in SQL</a> - grouping, bucketing, and segmenting users, dates, and events in SQL, from simple to complex cases.&nbsp;</p></li></ul><ul><li><p><a href="https://codingsight.com/practical-use-of-sql-coalesce-function">A Practical Use of the SQL COALESCE Function</a>&nbsp;</p></li><li><p><a href="https://coffingdw.com/snowflake-analytics-part-5-mdiff/">Snowflake Analytics &#8211; Moving Difference</a></p></li><li><p><a href="https://codingsight.com/introduction-to-temporary-tables-in-sql-server/">Introduction to Temporary Tables in SQL Server</a></p></li><li><p><a href="https://www.youtube.com/watch?v=UFiZx5NlzL4">SQL Workshop: SQL Patterns Every Analyst Should Know</a> with <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Ergest Xheblati&quot;,&quot;id&quot;:245231,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/aaddbcf6-d951-47e5-a3a5-4ecb90cffc35_3644x2732.jpeg&quot;,&quot;uuid&quot;:&quot;211a2f32-8b2e-4ae2-ab17-46abd172bf94&quot;}" data-component-name="MentionToDOM"></span>from <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Data Patterns&quot;,&quot;id&quot;:20473,&quot;type&quot;:&quot;pub&quot;,&quot;url&quot;:&quot;https://open.substack.com/pub/ergestx&quot;,&quot;photo_url&quot;:null,&quot;uuid&quot;:&quot;f8a581b3-7979-45b9-934c-00673d535a84&quot;}" data-component-name="MentionToDOM"></span> (so you know it is good).&nbsp;</p></li><li><p><a href="https://medium.com/analytics-vidhya/sql-cheat-sheet-for-data-science-cf3005c0fb28">SQL Cheat-Sheet for Data Science</a></p></li><li><p><a href="https://tanelpoder.com/posts/reasons-why-select-star-is-bad-for-sql-performance/">Reasons why SELECT * is bad for SQL performance</a> - this article is more targeted toward DE, but the second part explains some good query plan optimization methods. </p></li><li><p><a href="https://codingsight.com/sql-drop-table-statement-and-various-use-cases">SQL DROP TABLE Statement and Various Use Cases</a>&nbsp;</p></li></ul><h3>&#129514; SQL for A/B Testing:</h3><ul><li><p><a href="https://medium.com/deliberate-data-science/experimentation-platform-in-a-day-c60646ef1a2">Experimentation Platform in a Day</a> - the first part of the article walks through the experimentation service setup, but the second has good handy SQL you can borrow to read the test.</p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-develop-a-highly-trusted-experiment">How To Develop a Highly Trusted Experiment Analysis Workflow</a> - where <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Chetan Sharma&quot;,&quot;id&quot;:39938477,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/6580eaef-e5f8-4f83-90ea-13f50ee47a7b_1310x1260.png&quot;,&quot;uuid&quot;:&quot;f459c755-d8a7-4c4c-a7ef-95d0c028ad5f&quot;}" data-component-name="MentionToDOM"></span> from <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;The Eppo Newsletter&quot;,&quot;id&quot;:385406,&quot;type&quot;:&quot;pub&quot;,&quot;url&quot;:&quot;https://open.substack.com/pub/eppo&quot;,&quot;photo_url&quot;:null,&quot;uuid&quot;:&quot;0b36a5ec-5027-4c37-be4a-a8f7ed91ed26&quot;}" data-component-name="MentionToDOM"></span> shares SQL for calculating metrics, experiment windows, excluding bias, etc.&nbsp;</p></li><li><p><a href="https://medium.com/@foundinblank/using-sql-to-summarize-a-b-experiments-d30428edfb55">Using SQL to Summarize A/B Experiment Results</a></p></li></ul><h2><strong>&#128640; Advance and become an expert&nbsp;</strong></h2><ul><li><p><a href="http://codingsight.com/how-to-parse-strings-like-a-pro-using-sql-substring/">How to Parse Strings Like a Pro Using SQL SUBSTRING() Function?</a></p></li><li><p><a href="https://codingsight.com/passing-data-table-as-parameter-to-stored-procedures/">Passing Data table as Parameter to Stored Procedures</a></p></li><li><p><a href="https://towardsdatascience.com/the-best-sql-template-for-customer-lifetime-value-56978b062c0b">The Best SQL Template for Customer Lifetime Value</a> - you&#8217;re welcome.</p></li><li><p><a href="https://www.lennysnewsletter.com/p/measuring-cohort-retention">SQL for getting cohorted user retention</a> by yours truly published in <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Lenny's Newsletter&quot;,&quot;id&quot;:10845,&quot;type&quot;:&quot;pub&quot;,&quot;url&quot;:&quot;https://open.substack.com/pub/lenny&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/40b73d36-7447-4f52-83b5-4bbf44b9324a_1200x1200.png&quot;,&quot;uuid&quot;:&quot;2fe3cbfb-3baa-4fd6-a4c7-73a9647de20c&quot;}" data-component-name="MentionToDOM"></span>.</p></li><li><p><a href="https://www.cybertec-postgresql.com/en/json-postgresql-how-to-use-it-right/">JSON IN POSTGRESQL: HOW TO USE IT RIGHT</a></p></li><li><p><a href="https://about.gitlab.com/blog/2016/03/18/fast-search-using-postgresql-trigram-indexes/">Postgres Full-Text Search</a></p></li><li><p><a href="https://mjk.space/advanced-sql-cte/">Advanced SQL - Common Table Expressions</a> - amazing piece on CTEs</p></li><li><p><a href="https://hoverbear.org/blog/postgresql-hierarchical-structures/">Hierarchical Structures in PostgreSQL</a> - aimed more for DE.</p></li></ul><h4>And some of my favorite publications from one and only <a href="https://dataanalysis.substack.com/p/expert-insight-haki-benita-choosing">Haki Benita</a> &#11088;:&nbsp;</h4><ul><li><p><a href="https://hakibenita.com/sql-for-data-analysis">Practical SQL for Data Analysis</a></p></li><li><p><a href="https://hakibenita.com/sql-group-by-first-last-value">How to Get the First or Last Value in a Group Using Group By in SQL</a></p></li><li><p><a href="https://hakibenita.com/sql-anomaly-detection">Simple Anomaly Detection Using Plain SQL</a></p></li><li><p><a href="https://hakibenita.com/sql-dos-and-donts">12 Common Mistakes and Missed Optimization Opportunities in SQL</a></p></li></ul><h4>Some of my <a href="https://dataanalysis.substack.com/s/sql">SQL publications</a> (available for paid subscribers):&nbsp;</h4><ul><li><p><a href="https://dataanalysis.substack.com/p/how-to-install-a-database-issue-42">How To Install A Database&nbsp;</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/joining-two-tables-that-are-not-related">Joining two tables that are not related by a foreign key relationship</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/user-segmentation-and-power-user-analysis-in-sql-182e6c040235">User Segmentation and Power User Analysis in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/getting-date-functions-in-sql-issue">Getting Date Functions in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/top-10-advanced-sql-functions-for">Top 10 Advanced SQL Functions For Data Analysis</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-measure-your-adjacent-users">How To Measure Your Adjacent Users</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-get-randomly-distributed-users">How To Get Randomly Distributed Users in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/when-simple-becomes-tricky-sql-case">When Simple Becomes Tricky: SQL CASE Statement</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-create-date-series-in-sql">How To Create Date Series in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/ranking-the-most-used-features-in">Ranking The Most Used Features in Your Product Using SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-get-paid-subscriptions-in">How To Get Paid Subscriptions In SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/sql-and-python-mistakes-to-avoid">SQL And Python Mistakes To Avoid</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-pass-a-sql-interview-for-a">How To Pass A SQL Interview For A Data Scientist Position</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-get-average-logins-per-user">How To Get Average Logins Per User Per Day in SQL</a></p></li></ul><h2><strong>&#128296; Practicing SQL on your own</strong></h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!q1Aq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!q1Aq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 424w, https://substackcdn.com/image/fetch/$s_!q1Aq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 848w, https://substackcdn.com/image/fetch/$s_!q1Aq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!q1Aq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!q1Aq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg" width="1456" height="661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!q1Aq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 424w, https://substackcdn.com/image/fetch/$s_!q1Aq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 848w, https://substackcdn.com/image/fetch/$s_!q1Aq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!q1Aq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F729adfc7-78c0-47aa-9b8f-856e0806bf70_1456x661.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The best way to practice SQL is in your local database. For this, you can install the <a href="https://www.postgresql.org/">PostgreSQL</a> database and use <a href="https://www.jetbrains.com/datagrip/">the DataGrip</a> client with it. This gives you the flexibility to design the schema the way you want and practice SQL from anywhere at any time.&nbsp;</p><p>If you want to go a simpler route, use <a href="http://sqlfiddle.com/">SQLFiddle</a> or <a href="https://www.db-fiddle.com/">DB-Feddle</a> tools. You can either paste your SQL there and polish the syntax or design your own table schema.&nbsp;</p><p>You can also try <a href="https://simplql.com/">Simplql</a> - an in-browser tool that lets you query data files with SQL without using a database. It does everything in the browser. Users can export the results from their queries in CSV or JSON. Easy, fast, and intuitive.&nbsp;</p><h2><strong>&#127891; Free SQL tutorials and courses</strong></h2><p>If you are a beginner looking for a quick tutorial on basics, check out <a href="https://sqlzoo.net/wiki/SQL_Tutorial">SQL Zoo</a>.</p><p><a href="https://mode.com/sql-tutorial/introduction-to-sql/">The SQL Tutorial for Data Analysis</a> - this is from Mode. The descriptions are spot on and the structure is good. They also have another - <a href="https://mode.com/sql-tutorial/intro-to-intermediate-sql/">The Intermediate SQL Tutorial</a>, which focuses more on functions and joins.&nbsp;</p><p><a href="http://www.sqlcourse2.com/">SQLCourse2.com</a> - an online interactive SQL tutorial, from basics to advanced topics. Very similar to <a href="https://www.w3schools.com/sql/">W3 school SQL</a>. Both are good if you are new to SQL.</p><p><a href="https://www.tutorialrepublic.com/sql-tutorial/">TutorialRepublic - SQL Tutorial</a> - I like this tutorial more, as it contains more specific examples, making it easier to understand.&nbsp;</p><p><a href="https://leetcode.com/problemset/database/">Leetcode - SQL</a> - a set of SQL problems and challenges by topic, from simple to difficult. I bet we all spent a good deal of hours there. A good source to test yourself.&nbsp;</p><p><a href="https://www.windowfunctions.com/">WindowFunctions </a>and <a href="https://www.pgcasts.com/">PG Casts</a> - more on an advanced side for SQL users. Postgres specific.&nbsp;</p><p>Another new <a href="https://urbizedge.com/sql-window-functions/?utm_source=substack&amp;utm_medium=email">SQL Window Functions tutorial</a> - everything you have to know about window functions. A detailed guide with examples and nice visuals.&nbsp;</p><h2>&#8265;&#65039; Interview preparation</h2><ul><li><p><a href="https://www.interviewquery.com/blog-sql-interview-questions/">50+ SQL Interview Questions and Answers (Updated for 2021)</a></p></li><li><p><a href="https://www.interviewbit.com/sql-interview-questions/">SQL Interview Questions</a>&nbsp;</p></li><li><p><a href="https://madisonmae.substack.com/p/mastering-the-sql-technical-interview">Mastering the SQL Technical Interview</a> from <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Madison Mae&quot;,&quot;id&quot;:66148605,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F85ad6273-a9b9-4151-b1ee-17bcf78e036b_48x48.png&quot;,&quot;uuid&quot;:&quot;42da9f21-b1f0-4610-a95c-9dd27dbe1c74&quot;}" data-component-name="MentionToDOM"></span></p></li></ul><div><hr></div><p>I continually update this list to keep it fresh and relevant, so please send me your favorite SQL links and sources that you think I should add!&nbsp;&nbsp;</p><p>Thanks for reading, everyone. Until next Wednesday!</p>]]></content:encoded></item><item><title><![CDATA[Top 10 Advanced SQL Functions For Data Analysis - Issue 151]]></title><description><![CDATA[A roundup of helpful SQL functions to leverage for statistics, data generation, processing, and analytics.]]></description><link>https://dataanalysis.substack.com/p/top-10-advanced-sql-functions-for</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/top-10-advanced-sql-functions-for</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 05 Jul 2023 12:02:29 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fef9b083a-6314-4afa-84ee-b152ab268bf7_1456x641.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Welcome to the Data Analysis Journal, a weekly newsletter about data science and analytics.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><p>It&#8217;s easy to get started with SQL and grasp its basics, but it takes a lot of time and practice to advance to a proficient level.</p><p>Naturally, many analysts leverage Python or R and supplement with Excel and different BI tools to save time and move faster instead of spending hours researching the right function, figuring out its applied use case, and polishing syntax.&nbsp;</p><p>Today I&#8217;ll cover my 10 concepts and complex functions of advanced querying with a focus on statistics and analysis, including some use cases and examples.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bD2m!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bD2m!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!bD2m!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!bD2m!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!bD2m!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bD2m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b938055-a38c-4380-86f3-f6702ace745b_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bD2m!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!bD2m!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!bD2m!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!bD2m!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b938055-a38c-4380-86f3-f6702ace745b_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>Between us, I believe, in a few years Python may become another <a href="https://stackoverflow.blog/2020/04/20/brush-up-your-cobol-why-is-a-60-year-old-language-suddenly-in-demand/">Cobol</a> (like R already did, in a way), and most statistics, ML, and analysis will be supported by SQL (like it already is!). </p><p>Regardless of what MongoDB (<a href="https://www.mongodb.com/nosql-explained/nosql-vs-sql">NoSQL databases offer many benefits over relational databases</a>) or ThoughtSpot (<a href="https://www.thoughtspot.com/fact-and-dimension/secret-self-service-bi-business-intelligence-success-thoughtspot">The Secret to Self-Service Success</a>) tells you, SQL is a must-have skill for everyone who has &#8220;data&#8221; or &#8220;analysis&#8221; in their title. It never hurts to invest in learning it, and it pays off regardless of the company, your career goals, or projects.</p><p>Below are some interesting advanced or underrated SQL functions that aim to speed up data manipulation, data generation, and analysis.&nbsp;</p><h2>Run your statistics in SQL</h2><p>You&#8217;re probably already aware of basic aggregations and math like AVG, MEDIAN, and MIN/MAX. You might <em>not </em>know that you also can use SQL to run most of the descriptive statistics and analytical operations on your dataset. Almost every SQL variation now supports these as a built-in (super helpful if you use SQL to support experimentation).&nbsp;</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/top-10-advanced-sql-functions-for">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[How To Get Average Logins Per User Per Day - Issue 143]]></title><description><![CDATA[SQL solution for getting average user activity per day for weekly or monthly reporting]]></description><link>https://dataanalysis.substack.com/p/how-to-get-average-logins-per-user</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/how-to-get-average-logins-per-user</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 10 May 2023 12:01:28 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa07eb2f3-a7d1-4543-ad0a-5f123312c368_1170x976.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Welcome to the <a href="https://dataanalysis.substack.com/">Data Analysis Journal</a>, a weekly newsletter about data science and analytics.</em></p><div><hr></div><p>Today&#8217;s topic is another variation of engagement analysis we do to better understand user behavior.&nbsp;</p><p>Earlier this year I shared <a href="https://dataanalysis.substack.com/p/the-frequency-of-user-activity-sql">The Frequency Of User Activity: SQL and Analysis</a> which helps us uncover the frequency of usage and learn the <strong>total number of days</strong> users were active in a month. It also helps us locate power users, which we can pull into the cohort for email and other marketing campaigns: </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C7wS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C7wS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 424w, https://substackcdn.com/image/fetch/$s_!C7wS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 848w, https://substackcdn.com/image/fetch/$s_!C7wS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 1272w, https://substackcdn.com/image/fetch/$s_!C7wS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C7wS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp" width="1456" height="849" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:849,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:43386,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!C7wS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 424w, https://substackcdn.com/image/fetch/$s_!C7wS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 848w, https://substackcdn.com/image/fetch/$s_!C7wS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 1272w, https://substackcdn.com/image/fetch/$s_!C7wS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff57e512c-74ec-4e99-b639-0e5fadd6a0be_1456x849.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><a href="https://dataanalysis.substack.com/p/the-frequency-of-user-activity-sql">The Frequency Of User Activity: SQL and Analysis</a></figcaption></figure></div><p>Below, I&#8217;ll be going one step further and showing you a way how to get the average number of logins, actions, transactions, or likes <strong>per user per day</strong> to better understand the <strong>volume of user activity</strong>.&nbsp;&nbsp;&nbsp;</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mIX2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mIX2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!mIX2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!mIX2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!mIX2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mIX2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mIX2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!mIX2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!mIX2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!mIX2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1eb7fcfc-7bf8-4516-9e7d-bec354b7846d_200x200.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>Let&#8217;s say that you started with the frequency of user activity analysis and confirmed that the majority of your core active users use your product daily. The next step is to deep dive into their daily usage to understand how many times users use the product per day, what the average daily usage is per week or per month, how it&#8217;s changing over time, and how it&#8217;s different across other platforms, locales, countries, or user segments.&nbsp;&nbsp;</p><p>Whenever I have to work with averages or medians, I prefer not to use product analytics tools, even though they make it very easy to get such stats there. My thinking:&nbsp;</p><h4>Suspiciously high averages</h4><p>In my experience, the averages I get with such tools are always significantly higher than they should be. I explain it via the <a href="https://dataanalysis.substack.com/p/do-you-over-report-dau-issue-139">tricky nature of events-based data</a> and always validate metrics against server-side (hopefully) or 3rd party data. So it&#8217;s a no-go without SQL here.&nbsp;</p><p>Make sure to compare your high-level activity events against Firebase and Google Analytics, and check the expected volume with SensorTower data, Appfigures, Apple / Google store, or data.ai.&nbsp;Hopefully, you have a match in DAU and can rely on the median, mode, and averages for logins, app opens, transactions, clicks, and more. </p><h4>Over-processed analytics</h4><p>Some digital analytics tools often do extra work for you and remove outliers, re-distributing the population of users to show you a &#8220;cleaned&#8221; normalized average that is supposed to mean something they think you are likely to search for. For example, if you want to explore how many times per day users use your app, the system may hide extreme values like users who opened the app only once, or users who opened it more than 50 times, and return you only the average number that is relevant for the majority of your users. Instead, I&#8217;m more comfortable exploring outliers (if a segment of users uses your app 50 times per day, you&#8217;d better know what works for them so well), and then removing them myself (if needed).&nbsp;</p><p>This is especially important for reporting the average time it takes for users to complete a funnel, activation, onboarding flow, transactions, etc.&nbsp;</p><h2>SQL for getting average logins per user per day</h2><blockquote><p>Task: get a monthly report of average logins per user per day, broken down by paid, trial, and free user type.</p></blockquote>
      <p>
          <a href="https://dataanalysis.substack.com/p/how-to-get-average-logins-per-user">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[A Selection Of SQL Tutorials - Issue 141]]></title><description><![CDATA[A roundup of my favorite free SQL tutorials and articles to either get started with or to keep your querying skills strong.]]></description><link>https://dataanalysis.substack.com/p/a-selection-of-sql-tutorials-issue-4dc</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/a-selection-of-sql-tutorials-issue-4dc</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 26 Apr 2023 12:01:52 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!hXLK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, and welcome to my<a href="https://dataanalysis.substack.com/"> Data Analytics Journal</a>, where I write about product analytics and data science.</p><p>This month paid subscribers learned about:</p><ul><li><p><a href="https://dataanalysis.substack.com/p/the-ultimate-guide-on-churn-reporting">The Ultimate Guide On Churn Reporting (And Its Technicalities)</a> - Everything about churn in SaaS: how to calculate churn rate, the best way to report it, how it is connected with retention, and how not to get lost in SaaS. It&#8217;s aimed at senior and higher-level analysts, as I had to go deep into the details of the complex churn reporting and subscription lifecycle.&nbsp;</p></li><li><p><a href="https://dataanalysis.substack.com/p/do-you-over-report-dau-issue-139">Do You Over-Report DAU?</a> - Yes, if you use sessions to report user activity. Learn why you might be likely to over-report DAU and MAU for mobile apps, common pitfalls with user activity events, and recommendations on how to set up proper analytics for DAU reporting.</p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-pass-a-sql-interview-for-a">How To Pass A SQL Interview For A Data Scientist Position</a> - an example of a technical coding interview question for a data science position at Meta with a few solutions for solving it. I&#8217;ll walk through the steps on how to best approach the problem and solve it in SQL.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p></li></ul><p>I officially declare April a SQL month.&nbsp;&nbsp;</p><p>As data becomes more accessible, data quality and cleanliness have developed into a separate discipline. To increase trust in data, we have to structure it - put constraints and relationships between tables. RDBs have naturally become more popular and efficient, which means that SQL continues to be a must-have skill within the analytical domain. You can&#8217;t progress without SQL today, regardless of which specialization in the data field you chose.&nbsp;</p><p>Many years ago, I started making a list of my favorite go-to videos, articles, and lessons which I still use and keep updating to this day. Below I want to share my refreshed list of mostly free SQL tutorials and practice sites.</p><p>I had to learn SQL at school, but many successful analysts I know are self-taught SQL coders. Personally, I wouldn&#8217;t recommend enrolling in bootcamps or expensive programs to learn SQL. Go through the publications and videos below, and I guarantee you will be comfortable within a few months. It&#8217;s all about practice.&nbsp;</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FXvp!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FXvp!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!FXvp!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!FXvp!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!FXvp!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FXvp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png" width="158" height="158" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:158,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FXvp!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!FXvp!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!FXvp!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!FXvp!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F10efa62c-513a-4862-8c9f-f0dcb5a6862e_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><h2>&#128756; Getting started</h2><ul><li><p><a href="https://www.sohamkamani.com/blog/2016/07/07/a-beginners-guide-to-sql/">A beginner's guide to SQL</a> - a little old, but still one of the best introductions I&#8217;ve seen.&nbsp;</p></li><li><p><a href="https://thoughtbot.com/blog/understanding-sql-join">Understanding SQL Join</a>&nbsp;</p></li><li><p><a href="https://vladmihalcea.com/sql-left-join/">SQL LEFT JOIN &#8211; A Beginner&#8217;s Guide</a> - a really good read from one of the engineering champions <a href="https://vladmihalcea.com/">Vlad Mihalcea</a>. I was such a fan of his writing. Unfortunately, over the years he journeyed from data to the darkness of the Java world. People don&#8217;t come back from there.</p></li><li><p><a href="https://www.pluralsight.com/guides/using-on-versus-where-clauses-to-combine-and-filter-data-in-postgresql-joins">Using ON Versus WHERE Clauses to Combine and Filter Data in PostgreSQL Joins</a> - this is one of the common interview questions for analysts.</p></li><li><p><a href="https://codingsight.com/learn-database-design-with-sql-server-management-studio/">Learn Database Design with SQL Server</a> - walks you through how to install a database, its terminology, fundamental concepts, usage, etc. Their walkthrough can be applied to other SQL variations besides SQL Server. If you are a MySQL user, here is a similar one - a <a href="https://www.mysqltutorial.org/">MySQL tutorial</a>.</p></li></ul><h2>&#128690; Become proficient</h2><ul><li><p><a href="https://towardsdatascience.com/take-your-sql-skills-to-the-next-level-by-understanding-the-self-join-75f1d52f2322">Understanding The Self Join</a> - this is one of a few good articles out there on self-join.</p></li><li><p><a href="https://www.metabase.com/learn/sql-questions/sql-best-practices">Best practices for writing SQL queries</a></p></li><li><p><a href="https://365datascience.com/tutorials/sql-tutorials/sql-best-practices/">SQL Best Practices - How to type code cleanly and perfectly organized</a></p></li><li><p><a href="https://towardsdatascience.com/top-5-sql-analytic-functions-every-data-analyst-needs-to-know-3f32788e4ebb">Top 5 SQL Functions</a></p></li><li><p><a href="https://coffingdw.com/snowflake-analytics-part-7-lag/">Snowflake Analytics &#8211; Lag</a></p></li><li><p><a href="https://fivetran.com/blog/bucketing-in-sql">Bucketing in SQL</a> - grouping, bucketing, and segmenting users, dates, and events in SQL, from simple to complex cases.&nbsp;</p></li></ul><ul><li><p><a href="https://codingsight.com/practical-use-of-sql-coalesce-function">A Practical Use of the SQL COALESCE Function</a>&nbsp;</p></li><li><p><a href="https://coffingdw.com/snowflake-analytics-part-5-mdiff/">Snowflake Analytics &#8211; Moving Difference</a></p></li><li><p><a href="https://codingsight.com/introduction-to-temporary-tables-in-sql-server/">Introduction to Temporary Tables in SQL Server</a></p></li><li><p><a href="https://www.youtube.com/watch?v=UFiZx5NlzL4">SQL Workshop: SQL Patterns Every Analyst Should Know</a> with <a href="https://twitter.com/ergestx">Ergest Xheblati</a> (so you know it is good).&nbsp;</p></li><li><p><a href="https://medium.com/analytics-vidhya/sql-cheat-sheet-for-data-science-cf3005c0fb28">SQL Cheat-Sheet for Data Science</a></p></li><li><p><a href="https://medium.com/deliberate-data-science/experimentation-platform-in-a-day-c60646ef1a2">Experimentation Platform in a Day</a> - the first part of the article walks through the experimentation service setup, but the second has good handy SQL you can borrow to read the test.</p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-develop-a-highly-trusted-experiment">How To Develop a Highly Trusted Experiment Analysis Workflow</a> - where <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Chetan Sharma&quot;,&quot;id&quot;:39938477,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/6580eaef-e5f8-4f83-90ea-13f50ee47a7b_1310x1260.png&quot;,&quot;uuid&quot;:&quot;0892d706-9d6b-46dc-ba40-76a602ae2108&quot;}" data-component-name="MentionToDOM"></span> shares SQL for calculating metrics, experiment windows, excluding bias, etc.&nbsp;</p></li><li><p><a href="https://medium.com/@foundinblank/using-sql-to-summarize-a-b-experiments-d30428edfb55">Using SQL to Summarize A/B Experiment Results</a></p></li><li><p><a href="https://tanelpoder.com/posts/reasons-why-select-star-is-bad-for-sql-performance/">Reasons why SELECT * is bad for SQL performance</a> - this article is more targeted toward DE, but the second part explains some good query plan optimization methods. Analysts must understand optimizations, especially working at smaller companies.</p></li><li><p><a href="https://codingsight.com/sql-drop-table-statement-and-various-use-cases">SQL DROP TABLE Statement and Various Use Cases</a>&nbsp;</p></li></ul><h2>&#128640; Advance and become an expert&nbsp;</h2><ul><li><p><a href="http://codingsight.com/how-to-parse-strings-like-a-pro-using-sql-substring/">How to Parse Strings Like a Pro Using SQL SUBSTRING() Function?</a></p></li><li><p><a href="https://codingsight.com/passing-data-table-as-parameter-to-stored-procedures/">Passing Data table as Parameter to Stored Procedures</a></p></li><li><p><a href="https://towardsdatascience.com/the-best-sql-template-for-customer-lifetime-value-56978b062c0b">The Best SQL Template for Customer Lifetime Value</a> - you&#8217;re welcome.</p></li><li><p><a href="https://www.lennysnewsletter.com/p/measuring-cohort-retention">SQL for getting cohorted user retention</a> - my guest post for <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Lenny Rachitsky&quot;,&quot;id&quot;:1849774,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/afba5161-65bb-4d99-8d6b-cce660917fa1_1540x1540.png&quot;,&quot;uuid&quot;:&quot;f683f966-b3ec-47aa-b1d9-6e887933d16a&quot;}" data-component-name="MentionToDOM"></span>.</p></li><li><p><a href="https://www.cybertec-postgresql.com/en/json-postgresql-how-to-use-it-right/">JSON IN POSTGRESQL: HOW TO USE IT RIGHT</a></p></li><li><p><a href="https://about.gitlab.com/blog/2016/03/18/fast-search-using-postgresql-trigram-indexes/">Postgres Full-Text Search</a></p></li><li><p><a href="https://mjk.space/advanced-sql-cte/">Advanced SQL - Common Table Expressions</a> - amazing piece on CTEs</p></li><li><p><a href="https://hoverbear.org/blog/postgresql-hierarchical-structures/">Hierarchical Structures in PostgreSQL</a> - aimed for data engineering. You will need this if you are the only data person on a small team doing all foundational things at once.&nbsp;</p></li></ul><p>And some of my favorite publications from one and only <a href="https://dataanalysis.substack.com/p/expert-insight-haki-benita-choosing">Haki Benita</a> &#11088;:&nbsp;</p><ul><li><p><a href="https://hakibenita.com/sql-for-data-analysis">Practical SQL for Data Analysis</a></p></li><li><p><a href="https://hakibenita.com/sql-group-by-first-last-value">How to Get the First or Last Value in a Group Using Group By in SQL</a></p></li><li><p><a href="https://hakibenita.com/sql-anomaly-detection">Simple Anomaly Detection Using Plain SQL</a></p></li><li><p><a href="https://hakibenita.com/python-dependency-injection">Stop Using datetime.now!</a></p></li><li><p><a href="https://hakibenita.com/sql-dos-and-donts">12 Common Mistakes and Missed Optimization Opportunities in SQL</a></p></li><li><p><a href="https://hakibenita.com/fast-load-data-python-postgresql">Fastest Way to Load Data Into PostgreSQL Using Python</a></p></li></ul><p>Some of my <a href="https://dataanalysis.substack.com/s/sql">SQL publications</a> (available for paid subscribers):&nbsp;</p><ul><li><p><a href="https://dataanalysis.substack.com/p/how-to-install-a-database-issue-42">How To Install A Database&nbsp;</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/joining-two-tables-that-are-not-related">Joining two tables that are not related by a foreign key relationship</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/user-segmentation-and-power-user-analysis-in-sql-182e6c040235">User Segmentation and Power User Analysis in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/day-of-the-week-analysis-in-sql-issue">Day Of The Week Analysis in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/getting-date-functions-in-sql-issue">Getting Date Functions in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/advanced-sql-functions-for-data-analysis">Advanced SQL Functions For Data Analysis</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-measure-your-adjacent-users">How To Measure Your Adjacent Users</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-get-randomly-distributed-users">How To Get Randomly Distributed Users in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/when-simple-becomes-tricky-sql-case">When Simple Becomes Tricky: SQL CASE Statement</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-create-date-series-in-sql">How To Create Date Series in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/ranking-the-most-used-features-in">Ranking The Most Used Features in Your Product Using SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-get-paid-subscriptions-in">How To Get Paid Subscriptions In SQL</a></p></li></ul><h2>&#128296; Practicing SQL</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!hXLK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!hXLK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 424w, https://substackcdn.com/image/fetch/$s_!hXLK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 848w, https://substackcdn.com/image/fetch/$s_!hXLK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 1272w, https://substackcdn.com/image/fetch/$s_!hXLK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!hXLK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png" width="1456" height="661" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!hXLK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 424w, https://substackcdn.com/image/fetch/$s_!hXLK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 848w, https://substackcdn.com/image/fetch/$s_!hXLK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 1272w, https://substackcdn.com/image/fetch/$s_!hXLK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff21379d4-6694-4e87-92b9-9744e4fcb2e5_1456x661.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The best way to practice SQL is in your local database. For this, you can install the <a href="https://www.postgresql.org/">PostgreSQL</a> database and use <a href="https://www.jetbrains.com/datagrip/">the DataGrip</a> client with it. This gives you the flexibility to design the schema the way you want and practice SQL from anywhere at any time.&nbsp;</p><p>If you want to go a simpler route, use <a href="http://sqlfiddle.com/">SQLFiddle</a> or <a href="https://www.db-fiddle.com/">DB-Feddle</a> tools. You can either paste your SQL there and polish the syntax or design your own table schema.&nbsp;</p><p>You can also try <a href="https://simplql.com/">Simplql</a> - an in-browser tool that lets you query data files with SQL without using a database. It does everything in the browser. Users can export the results from their queries in CSV or JSON. Easy, fast, and intuitive.&nbsp;</p><h3><strong>&#127891; SQL Tutorials</strong></h3><p>If you are new to SQL and are looking for a quick tutorial on basics, check out <a href="https://sqlzoo.net/wiki/SQL_Tutorial">SQL Zoo</a>.</p><p><a href="https://mode.com/sql-tutorial/introduction-to-sql/">The SQL Tutorial for Data Analysis</a> - this is from Mode. The descriptions are spot on and the structure is good. They also have another - <a href="https://mode.com/sql-tutorial/intro-to-intermediate-sql/">The Intermediate SQL Tutorial</a>, which is more focused on functions and joins.&nbsp;</p><p><a href="http://www.sqlcourse2.com/">SQLCourse2.com</a> - an online interactive SQL tutorial, from basics to advanced topics. Very similar to <a href="https://www.w3schools.com/sql/">W3 school SQL</a>. Both are good if you are new to SQL.</p><p><a href="https://www.tutorialrepublic.com/sql-tutorial/">TutorialRepublic - SQL Tutorial</a> - I like this tutorial more, as it contains more specific examples, making it easier to understand.&nbsp;</p><p><a href="https://leetcode.com/problemset/database/">Leetcode - SQL</a> - a set of SQL problems and challenges by topic, from simple to difficult. I bet we all spent a good deal of hours there. A good source to test yourself.&nbsp;</p><p><a href="https://www.windowfunctions.com/">WindowFunctions </a>and <a href="https://www.pgcasts.com/">PG Casts</a> - more on an advanced side for SQL users. Postgres specific.&nbsp;</p><h2>&#8265;&#65039; Interview preparation</h2><ul><li><p><a href="https://www.interviewquery.com/blog-sql-interview-questions/">50+ SQL Interview Questions and Answers (Updated for 2021)</a></p></li><li><p><a href="https://www.interviewbit.com/sql-interview-questions/">SQL Interview Questions</a>&nbsp;</p></li><li><p><a href="https://madisonmae.substack.com/p/mastering-the-sql-technical-interview">Mastering the SQL Technical Interview</a> from <span class="mention-wrap" data-attrs="{&quot;name&quot;:&quot;Madison Mae&quot;,&quot;id&quot;:66148605,&quot;type&quot;:&quot;user&quot;,&quot;url&quot;:null,&quot;photo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F85ad6273-a9b9-4151-b1ee-17bcf78e036b_48x48.png&quot;,&quot;uuid&quot;:&quot;1afd3e01-160a-4327-a302-75bf2aa86df9&quot;}" data-component-name="MentionToDOM"></span> (yes, we both coincidentally decided to cover SQL at the same time).</p></li></ul><div><hr></div><p>I continually update this list to keep it fresh and relevant, so please send me your favorite SQL links and sources that you think I should add!&nbsp;&nbsp;</p><p>Thanks for reading, everyone. Until next Wednesday!</p>]]></content:encoded></item><item><title><![CDATA[How To Pass A SQL Interview For A Data Scientist Position - Issue 140]]></title><description><![CDATA[A case study challenge breakdown for a data scientist position solved in SQL]]></description><link>https://dataanalysis.substack.com/p/how-to-pass-a-sql-interview-for-a</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/how-to-pass-a-sql-interview-for-a</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 19 Apr 2023 12:01:33 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!q7kQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cbaa7db-1784-4c38-a23d-60cdb013165c_760x320.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Welcome to the <a href="https://dataanalysis.substack.com/">Data Analysis Journal</a>, a weekly newsletter about product analytics and data science.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p><div><hr></div><p>With continuing layoffs this year, I know many analysts are interviewing now. Today I want to share an example of a technical coding interview question for a data science position at Meta - and offer one of the solutions for solving it. I&#8217;ll walk through the steps on how to best approach and break down the problem and solved it using SQL.&nbsp;</p><p>Data Science is a cross-functional role, and candidates are tested across product and business acumen, data analysis, statistics, and modeling. The technical interview consists of Python and SQL questions. I covered an example of a Python interview a few months ago (read <a href="https://dataanalysis.substack.com/p/how-to-pass-a-technical-assignment">How To Pass A Technical Assignment For Senior Data Scientist Position</a>), but today will focus solely on a SQL challenge that is aimed to test not only candidates&#8217; code level proficiency but also business knowledge. For this task, it is expected you are proficient in SQL and data analysis.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!D6_7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!D6_7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!D6_7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!D6_7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!D6_7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!D6_7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!D6_7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!D6_7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!D6_7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!D6_7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c4b9bb8-8b7c-46c4-a5be-3ad3320e475b_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div>
      <p>
          <a href="https://dataanalysis.substack.com/p/how-to-pass-a-sql-interview-for-a">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Getting Date Functions in SQL - Issue 136]]></title><description><![CDATA[A quick lookup one-pager for common DATE functions in SQL]]></description><link>https://dataanalysis.substack.com/p/getting-date-functions-in-sql-issue</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/getting-date-functions-in-sql-issue</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 15 Mar 2023 12:01:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!R6vJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73d8fe4-b14d-4eb2-8218-beba140813f2_1722x1530.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Recently I received a request to break down common SQL Date functions but make them &#8220;business user-friendly&#8221; &#129300;&#9760;&#65039;.</p><p>My natural response to PMs, business, and marketing partners who ask if they should learn SQL to be better at their job is <strong>NO</strong>, because:</p><ol><li><p>Not-optimized queries or SELECT* in production in RedShift or Postgres bring nothing but a wailing and great looming despair to the one and only DE person in house. </p></li><li><p>There are so many tools out there that aim to take this burden from you, show you data at your fingertips, and save you many hours of learning SQL. Many of these tools are free or becoming more affordable even if you have a tight budget (e.g. Google Analytics, Adobe Analytics, Firebase, Appfigures, Clicky, Hotjar, HubSpot, Smartlook, Bitly, and Google Search Console. I believe Mixpanel and Heap also both have a free basic plan).</p></li><li><p>There is so much context required on the data source, data value, and limitations of that table you query, and that context is crucial to the question you want to answer. Unless you are involved in every stage of that event or transaction data lifecycle and understand all in and outs, you are likely to get the wrong data or misleading data.&nbsp;</p></li></ol><p>Normally, I am not a fan of democratizing SQL usage for product or business stakeholders, because, in 98% of cases that I&#8217;ve experienced, an analyst has had to redo the pull, and then restate the numbers, and then correct assumptions.&nbsp;</p><p>But it has been a difficult week, and we all would appreciate a distraction from financial markets analysis and commentary. When the world goes dark and uncertain, I find it&#8217;s best to be reminded of the foundation that holds all of us together: family, friends, and a relational database.</p><p>So I decided to do just that this week - publish a SQL guide on Date and Time formatting, hopefully making it business user-friendly and providing pointers on which function to use for which question or case.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!-kIU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!-kIU!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!-kIU!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!-kIU!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!-kIU!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!-kIU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!-kIU!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!-kIU!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!-kIU!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!-kIU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd51d854-0270-4b4b-957a-1b0adb0b148c_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div>
      <p>
          <a href="https://dataanalysis.substack.com/p/getting-date-functions-in-sql-issue">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[When Simple Becomes Tricky: SQL CASE Statement - Issue 132]]></title><description><![CDATA[How to apply CASE conditional expressions to specify a result when there are multiple conditions.]]></description><link>https://dataanalysis.substack.com/p/when-simple-becomes-tricky-sql-case</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/when-simple-becomes-tricky-sql-case</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 15 Feb 2023 13:01:50 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!JoCW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7129616c-ef75-41d6-ad28-3565367a58d1_1456x714.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><p>It&#8217;s Wednesday, and I am back with another SQL how-to for <em>your </em>enjoyment.&nbsp;</p><p>Today&#8217;s topic is not new to anyone who works with SQL - it&#8217;s the famous CASE statement! This is SQL 101, and I expect that you have mastered it since back in the <a href="https://dataanalysis.substack.com/p/sql-case-conditional-expression-guide">early days</a> of my newsletter. For this publication, I have 2 main objectives: brush up and re-introduce the concept of CASE statements (neither you nor I can afford becoming rusty with a foundation), as well as remind all of us how easily mistakes can slip in and become overlooked. </p><h6>It may or may not be inspired by me messing up with a CASE issue the other day.</h6><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!myMb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!myMb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!myMb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!myMb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!myMb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!myMb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!myMb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!myMb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!myMb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!myMb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2ec63df8-f388-4493-98d9-3fd9fed5eec3_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div>
      <p>
          <a href="https://dataanalysis.substack.com/p/when-simple-becomes-tricky-sql-case">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[How To Measure Your Adjacent Users - Issue 130]]></title><description><![CDATA[A practical guide on how to locate and measure a tricky product persona of adjacent users in SQL, and challenges of getting such analysis in product analytics tools]]></description><link>https://dataanalysis.substack.com/p/how-to-measure-your-adjacent-users</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/how-to-measure-your-adjacent-users</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 01 Feb 2023 13:01:02 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!mSDx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In 2020 the product growth world was disrupted by a sensational guest post on Andrew Chen's blog - <a href="https://andrewchen.com/the-adjacent-user-theory/">The Adjacent User Theory</a>, written by <a href="https://www.linkedin.com/in/iambangaly/">Bangaly Kaba</a>, a Reforger and Former VP Growth @Instacart, Instagram. It quickly was picked up and referenced by every trendy growth advisor, reposted, and republished almost <em>too </em>many times across <a href="https://brianbalfour.com/quick-takes/the-adjacent-user">Reforge</a>, <a href="https://productled.com/blog/growth-framework-jtbd/">ProductLed</a>, <a href="https://medium.com/@1000TrueFans/the-adjacent-user-theory-994df89d112f">Medium</a>, <a href="https://userpilot.com/blog/adjacent-users/">UserPilot</a>, <a href="https://news.ycombinator.com/item?id=23901366">Y Combinator</a>, and more (including <a href="https://dataanalysis.substack.com/p/improving-user-retention-expert-insights">yours truly</a>).&nbsp;</p><p>It was (and still is) &#8220;big&#8221; because it pointed to both the painful and the obvious by offering examples, and also provided a framework to follow to scale your growth, nicely structured and backed up with data. It was not entirely new, as the concept of these users was around for many ages across many marketing books, publications, and blogs (Paul Graham, Patrick Collison, Avinash Kaushik, to name a few). But once it gets a weird name, a few unicorn references, and a round <s>funnel</s> (pardon me: <em>loop chart),</em> it quickly becomes a new successful &#8220;theory&#8221; and a playbook with a proven record of hacking the growth.&nbsp;</p><p>It inevitably affected product analytics, as every PLG-determined product owner began scraping their analytic tool to locate these adjacent users to answer what exactly doesn&#8217;t work for them and why that might be. Failing to find the right cohorts, they looked to their brave and brilliant analysts with a request to locate, estimate, and pull these users for a deep-dive study across their demographics, behavior, attributes, and tenure.&nbsp;</p><p>Finding these users, even for experienced analysts, is not simple or intuitive. It requires a thorough understanding of a user base, its dynamics, and user behavior, but foremost: having matured analytics in-house to provide you with sufficient user attributes. This is often not a luxury to have at small and even mid-size companies, not to mention the historical data you need to have for defining your personas.&nbsp;</p><p>I think I went through every article, reference, tweet, and post on adjacent users from trendy growth advisors and hobbyists out there. As expected, there was a flood of opinions about &#8220;what&#8221; and &#8220;why&#8221;, but not a single practical guide on &#8220;how&#8221;. So here it is! My walkthrough and solution (in SQL because after many months of trying I couldn&#8217;t figure out a trusted way to do so in product analytics tools) on<strong> how to locate those malicious adjacent users in your userbase</strong>. I&#8217;ll then take a look at why product analytics tools still fall short to support you in such analysis.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!v2SN!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v2SN!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!v2SN!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!v2SN!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!v2SN!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v2SN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!v2SN!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!v2SN!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!v2SN!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!v2SN!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9be754c1-e538-4d37-9bf5-63df1637714d_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><h2><strong>To recap: who are Adjacent users, and why are they important?</strong></h2><p>An adjacent user is a product persona along with power, core, casual, activated, new, and visitors personas that make up your whole user base. This is a group of users who know about your product but haven&#8217;t become engaged users yet.</p><p>Some quick takes from <strong><a href="https://www.linkedin.com/posts/iambangaly_the-adjacent-user-theory-activity-6691119042855485440-e_-K/">Bangaly Kaba</a></strong>:</p><ul><li><p>Adjacent users are aware of and have possibly tried using the product, but are not able to successfully become engaged users.</p></li><li><p>This is typically because the current product positioning or experience has too many barriers to adoption for them.</p></li><li><p>Building empathy for the adjacent user is hard because, by definition, your team is not living the experience of the adjacent user. Your team are power users of the product.</p></li><li><p>The most successful companies are the ones that can continuously evolve to serve more adjacent users. The art is selecting the right groups of adjacent users to go after next.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!mSDx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!mSDx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 424w, https://substackcdn.com/image/fetch/$s_!mSDx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 848w, https://substackcdn.com/image/fetch/$s_!mSDx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!mSDx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!mSDx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:299189,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!mSDx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 424w, https://substackcdn.com/image/fetch/$s_!mSDx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 848w, https://substackcdn.com/image/fetch/$s_!mSDx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!mSDx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F189c7a96-c5fc-4da2-a91a-4de619017615_1920x1080.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><strong><a href="https://andrewchen.com/the-adjacent-user-theory/">The Adjacent User Theory</a></strong></figcaption></figure></div><p>The adjacent user is critical to locate and measure because it helps you capture the full potential of your product marketing positioning.</p><p>To convert the adjacent Users into your power Users, you have to know <em><strong>who is successful today and why</strong></em>. This gives you a number of user characteristics that help you to differentiate the &#8220;powerful&#8221; category from the adjacent one.</p><p>Here are four techniques Bangaly <a href="https://andrewchen.co/the-adjacent-user-theory/">recommends</a>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MxiG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MxiG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 424w, https://substackcdn.com/image/fetch/$s_!MxiG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 848w, https://substackcdn.com/image/fetch/$s_!MxiG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!MxiG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MxiG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png" width="1456" height="819" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:819,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:208921,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MxiG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 424w, https://substackcdn.com/image/fetch/$s_!MxiG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 848w, https://substackcdn.com/image/fetch/$s_!MxiG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 1272w, https://substackcdn.com/image/fetch/$s_!MxiG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb916003-05c2-4e67-944d-c1c07c49940d_1920x1080.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption"><strong><a href="https://andrewchen.com/the-adjacent-user-theory/">The Adjacent User Theory</a></strong></figcaption></figure></div><h2><strong>Why adjacent users are challenging to locate using product analytics tools</strong></h2><p>It&#8217;s a hit-or-miss to leverage product analytics tools today, like Amplitude, Heap, or Mixpanel to locate and define your adjacent users. Even assuming that (a) your analytical setup is rich and (b) you have all the activity events and properties you need, and (C) you also have enough historical data for all the events, you still face multiple challenges with this specific cohort:</p><h4><strong>1. Adjacent users group is mixed</strong></h4><p>Unlike other product personas, the adjacent users group is <strong>mixed</strong>.&nbsp;</p><p>By its definition, this group is across different stages of your product lifecycle (e.g it&#8217;s in your signup funnel, activation funnel, top features, rare-used features, paid subscriptions, free usage, etc) You can&#8217;t simply pick a specific event, and list a few user attributes and wrap it in a cohort group (like you would do with the activated or core users). You literally have to select every event you have with every user property your analytics has. You probably don&#8217;t want to use &#8220;any active event&#8221; (as a common option) because login, app open or screen view won&#8217;t be sufficient. You would need to create a custom event and come up with over-complicated dates logic to figure out the right frequency of usage.</p><h4><strong>2. Adjacent users group is dynamic</strong></h4><p>As I said above, this group will contain all types of users you pull into your funnel with various attributes and properties. In my experience, you will need to leverage more <strong>user properties</strong> instead of <strong>event properties</strong> to define a cohort.&nbsp;</p><p>The common challenge with user properties is that <strong>you can have only one value per user for a particular event</strong>. So you have to set the logic for which value to pick up - (1) the initial one or (2) the latest one. Both cases are bad for analytics: </p><ul><li><p>Case 1: the initial value will stay the same for that user and won&#8217;t be overridden by the most recent value. </p></li><li><p>Case 2: the latest value will override the previous value for that user.&nbsp;</p></li></ul><p>For example, let&#8217;s say a user purchased a paid subscription. The user property in your analytics might be <code>user_status = paid</code>. Then let&#8217;s say a user canceled a subscription, so the new user property value for that user will be updated (hopefully, if you do Case 2 above) to <code>user_status = free</code>. So now, in your analytics, this user will be shown as free. Often, there is no way for you to see if this user ever was a paid customer before in your funnel or a cohort. Or there is no way to specify - this user never was a customer. Having these filters is crucial to locate our group.</p><h4><strong>3. Adjacent users group is large</strong></h4><p>This might not be a concern for your team or product, depending on your plan and the volume of events, but it was very much a constraint for multiple clients I worked with.&nbsp;</p><p>Be prepared, for unlike power or premium users, the group of adjacent users is large. I believe this is one of the largest personas you have to aim for when iterating your product. You might not be able to simply export it and pass it to your marketing or research teams for further study. You won&#8217;t be able to pull a list of different characteristics for these users all at once, too.&nbsp;</p><h4><strong>4. You can&#8217;t check yourself</strong></h4><p>The challenge with creating product personas is that you must be imbued with the highest confidence that <strong>users in your group share similar characteristics</strong>. That&#8217;s the whole purpose of personas - finding randomly distributed users who share something common with each other.&nbsp;</p><p>To validate that your users are correctly grouped, you need to run them against multiple attributes to ensure exactly these 5K users all have a specific event on X day, X week, using X feature, having X number of actions, etc. The only way to do it in Amplitude or similar tools is to look up a specific user and open a log of their activity and endlessly browse through hundreds of events hoping to find THAT one. There is no way of doing so for a group of users.&nbsp;</p><p>When product tools fall short of flexibility and trust, old-fashioned data analytics comes to the rescue. Is that a bird? A plane? A nonsensical spreadsheet? No. It&#8217;s SQL, here to save the day (and your analytics).&nbsp;</p><h1><strong>Getting adjacent users in SQL</strong></h1>
      <p>
          <a href="https://dataanalysis.substack.com/p/how-to-measure-your-adjacent-users">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[How To Get Randomly Distributed Users in SQL - Issue 123]]></title><description><![CDATA[Some simple and quick ways to apply sampling techniques for your analysis to get random users.]]></description><link>https://dataanalysis.substack.com/p/how-to-get-randomly-distributed-users</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/how-to-get-randomly-distributed-users</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 14 Dec 2022 13:01:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!BQyf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Faba272ac-204b-4184-b1db-5bc8ded8122e_1370x470.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I find it fascinating that today you can complete the full analysis lifecycle using only SQL without supplementing it with Python or Excel (without visualizations, of course). This is in lieu of when I also <a href="https://dataanalysis.substack.com/p/the-top-10-best-blogs-to-read-for">wrote about all the cool things</a> you can do in SQL, from EDA to formatting, to forecasting, to advanced stats.&nbsp;</p><p>Today&#8217;s topic is about how to apply different sampling techniques in SQL for your analysis - select a representative subset of data to identify patterns and trends in the larger data set. While SQL is not the best tool for getting randomly, uniformly, or normally distributed users (that&#8217;s where you would have to supplement with Python), you can make it work in SQL as well, and below, I&#8217;ll show you how.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1juv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1juv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!1juv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!1juv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!1juv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1juv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/d7be7427-e611-43a8-a345-6ac384eefdee_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1juv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!1juv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!1juv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!1juv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd7be7427-e611-43a8-a345-6ac384eefdee_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><h2><strong>When do you need to get randomly distributed users?</strong></h2>
      <p>
          <a href="https://dataanalysis.substack.com/p/how-to-get-randomly-distributed-users">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Joining Two Tables That Are Not Related By A Foreign Key Relationship - Issue 119]]></title><description><![CDATA[How to connect two tables that are not related by a foreign key relationship in PostgreSQL]]></description><link>https://dataanalysis.substack.com/p/joining-two-tables-that-are-not-related</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/joining-two-tables-that-are-not-related</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 16 Nov 2022 15:00:35 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!HD_0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><p>This publication was created after many late hours spent trying to figure out a way to merge two datasets into one consolidated data source for a trickly dashboard chart. It was back in 2015 (wow, time flies) for a popular (at the time) dashboarding tool called Chartio.&nbsp;</p><p>A few weeks ago I received a cry for help from one of my readers who was stuck with the same problem I did back then. So today I decided to repost this article to share my solution which is not very intuitive for analysts, but is also simple and saves the day. This challenge is common in analytics, and the proposed workaround is a systematic approach in analytics engineering.&nbsp;&nbsp;</p><p><strong>This post will focus on SQL joins and will show you a way to connect two tables that are not related by a foreign key relationship.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KJgK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KJgK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!KJgK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!KJgK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!KJgK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KJgK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png" width="154" height="154" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/e28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:154,&quot;bytes&quot;:2197,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KJgK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!KJgK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!KJgK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!KJgK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fe28a3817-fa29-40ec-a9ce-362977a7e759_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p>As you may know, joins are used to combine or merge data from different tables. The way you combine them depends on the type of join you use. In order to join two or more tables, they <strong>have to be related by a key</strong>; if not, it&#8217;s not easy to join them. </p><p>Theoretically, you wouldn&#8217;t run into this case at all, because the whole point of doing a join is to extract data that has a specific relationship between tables. If there is no relationship, why would you need to join?</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HD_0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HD_0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 424w, https://substackcdn.com/image/fetch/$s_!HD_0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 848w, https://substackcdn.com/image/fetch/$s_!HD_0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!HD_0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HD_0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg" width="240" height="251.66666666666666" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:755,&quot;width&quot;:720,&quot;resizeWidth&quot;:240,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HD_0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 424w, https://substackcdn.com/image/fetch/$s_!HD_0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 848w, https://substackcdn.com/image/fetch/$s_!HD_0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!HD_0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F910a80ae-0d43-4f27-904a-73e615e245ee_720x755.jpeg 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h3><strong>The challenge</strong></h3><p><strong>Here&#8217;s one scenario: </strong>let&#8217;s say you receive payment data via API from third parties, like Stripe, PayPal, ApplePay, GooglePay, etc. Every payment provider has its own list of events and transactions, but there is no common ID or unifier between all of them. You have to merge providers to report on total paying users, new transactions, cancellations, and so on. But the looming question is if there is no common ID or USER_ID or anything unifying between these payment providers, <em>how </em>will you join these datasets?&nbsp;</p><p><strong>Here&#8217;s another scenario:</strong> data analysts often work with different visualization tools that are piping data from a database and a&nbsp;universe of sources, including all flavors of analytic tools, applications, and CSV files. Merging sources using common events or IDs between them is not always a luxury we can have. Depending on the tool, this is usually solvable with a degree of complexity, but despite my obviously stunning knowledge of all things analytics, I couldn&#8217;t figure out a way to do that in Chartio.&nbsp;&nbsp;&nbsp;</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/joining-two-tables-that-are-not-related">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Ranking The Most Used Features in Your Product Using SQL - Issue 113]]></title><description><![CDATA[How to get the most popular features, products, or user activity in SQL]]></description><link>https://dataanalysis.substack.com/p/ranking-the-most-used-features-in</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/ranking-the-most-used-features-in</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 05 Oct 2022 14:01:11 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!OaQ2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Can you believe it&#8217;s October already? Bring on the last quarter of the year! Let it also serve as a gentle reminder that you have 3 more months to hit all your milestones and resolutions this year.&nbsp;&nbsp;</p><p>This week, I&#8217;d like to explore a common question in product analytics - which features in your product do users use the most?&nbsp;</p><p>Let&#8217;s say you are on a quest to boost your ARR aggressively and want to paywall the top 3 most popular features. How do you figure out which features are the most used across all your customers?&nbsp;&nbsp;</p><p>Or here&#8217;s another scenario: a Product Manager watches the last glimmer of hope drain from their eyes and considers <a href="https://www.lennysnewsletter.com/p/when-to-sunset-a-feature">sunsetting a feature</a>. The first step in such decision-making is figuring out what the feature usage is - how many users are engaging with this product? Are they engaging at all? How can you get this data?&nbsp;&nbsp;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OaQ2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OaQ2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 424w, https://substackcdn.com/image/fetch/$s_!OaQ2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 848w, https://substackcdn.com/image/fetch/$s_!OaQ2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 1272w, https://substackcdn.com/image/fetch/$s_!OaQ2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OaQ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png" width="1448" height="798" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/dedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:798,&quot;width&quot;:1448,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:722861,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OaQ2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 424w, https://substackcdn.com/image/fetch/$s_!OaQ2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 848w, https://substackcdn.com/image/fetch/$s_!OaQ2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 1272w, https://substackcdn.com/image/fetch/$s_!OaQ2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fdedd5ac9-78f6-4d9f-be98-612911c577a6_1448x798.png 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><h6><em>from Lenny&#8217;s <a href="https://www.lennysnewsletter.com/p/when-to-sunset-a-feature">When to sunset a feature</a></em></h6><p>Below I will offer a simple solution using SQL.&nbsp;</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!tBO0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!tBO0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!tBO0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!tBO0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!tBO0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!tBO0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!tBO0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!tBO0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!tBO0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!tBO0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55e046-1f87-4080-bd59-01ca1f36f49b_200x200.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><p>This question was my favorite task to provide analysts with during technical interviews. Depending on your data health and variability of product features, it&#8217;s somewhere between an intermediate and an advanced level - analyzing user activity by applying SQL rank function.&nbsp;</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/ranking-the-most-used-features-in">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[A Selection Of SQL Tutorials - Issue 77]]></title><description><![CDATA[A roundup of my favorite free SQL tutorials and articles to either get started with or to keep your querying skills strong.]]></description><link>https://dataanalysis.substack.com/p/a-selection-of-sql-tutorials-issue</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/a-selection-of-sql-tutorials-issue</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 19 Jan 2022 17:30:41 GMT</pubDate><enclosure url="https://cdn.substack.com/image/fetch/h_600,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, data people!&nbsp;</p><p>We are halfway through January, and I have already given up on my resolutions. Who cares about healthy eating anyway, as we&#8217;ll soon all move into VR and transcend our bodies.&nbsp;</p><p><a href="https://dataanalysis.substack.com/p/a-selection-of-python-tutorials-for">As promised earlier</a>, today&#8217;s newsletter is all about SQL. Many years ago I started making a list of my favorite go-to videos, articles, and lessons which I still use and keep updating to this day. In this issue, I am going to save you hours of research and share my list of free SQL tutorials and practice sites for data acquisition and analysis.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aW68!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aW68!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!aW68!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!aW68!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!aW68!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aW68!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png" width="158" height="158" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:158,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aW68!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!aW68!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!aW68!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!aW68!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F6c44277e-6676-4be8-a65e-a8c3cda8bd15_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://dataanalysis.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://dataanalysis.substack.com/subscribe?"><span>Subscribe now</span></a></p><p>A quick preface: given how quickly tech and analytical states develop, RDBs naturally become more popular and efficient by proxy. As data becomes more accessible, data quality and cleanliness develop into a separate discipline. To increase trust in data, we have to structure it - put constraints and relationships between tables (love the way that sounds). It means SQL knowledge becomes more essential and popular within the analytical domain. You can&#8217;t progress without SQL today.&nbsp;</p><p>Some of the sources below I&#8217;ve used since 2014 or so. Most of those are (or were) free, but things change, so it is possible some of the classes are not free anymore.&nbsp;</p><h3><strong>&#128756; Getting started</strong></h3><ul><li><p><a href="https://codingsight.com/learn-database-design-with-sql-server-management-studio/">Learn Database Design with SQL Server</a> - This will walk you through how to install a database, its terminology, fundamental concepts, usage, etc. Their walkthrough can be applied to other SQL variations besides SQL Server. If you are a MySQL user, here is a similar one - <a href="https://www.mysqltutorial.org/">MySQL tutorial</a>.</p></li><li><p><a href="https://www.sohamkamani.com/blog/2016/07/07/a-beginners-guide-to-sql/">A beginners guide to SQL</a> - a little old, but I think this is one of the best introductions I have seen.&nbsp;</p></li><li><p><a href="https://thoughtbot.com/blog/understanding-sql-join">Understanding SQL Join</a>&nbsp;</p></li><li><p><a href="https://medium.com/analytics-vidhya/mastering-sql-queries-166e278d9582">Mastering SQL Queries</a></p></li><li><p><a href="https://vladmihalcea.com/sql-left-join/">SQL LEFT JOIN &#8211; A Beginner&#8217;s Guide</a> - a really good read. The author is a rockstar and I&#8217;m such a fan of his writing.&nbsp;&nbsp;</p></li><li><p><a href="https://towardsdatascience.com/take-your-sql-skills-to-the-next-level-by-understanding-the-self-join-75f1d52f2322">Understanding The Self Join</a></p></li><li><p><a href="https://www.pluralsight.com/guides/using-on-versus-where-clauses-to-combine-and-filter-data-in-postgresql-joins">Using ON Versus WHERE Clauses to Combine and Filter Data in PostgreSQL Joins</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/sql-hack-how-to-create-user-profiles">How To Create User Profiles in SQL</a>&nbsp;</p></li><li><p><a href="https://dataanalysis.substack.com/p/sql-case-conditional-expression-guide">SQL CASE Conditional Expression Guide</a></p></li><li><p><a href="https://coffingdw.com/snowflake-analytics-part-7-lag/">Snowflake Analytics &#8211; Lag</a></p></li><li><p><a href="https://www.edureka.co/blog/interview-questions/sql-interview-questions">Top 117 SQL Interview Questions and Answers for 2024</a></p></li></ul><h3><strong>&#128690; Become proficient</strong></h3><ul><li><p><a href="https://www.metabase.com/learn/sql-questions/sql-best-practices">Best practices for writing SQL queries</a></p></li><li><p><a href="https://365datascience.com/tutorials/sql-tutorials/sql-best-practices/">SQL Best Practices - How to type code cleanly and perfectly organized</a></p></li><li><p><a href="https://towardsdatascience.com/top-5-sql-analytic-functions-every-data-analyst-needs-to-know-3f32788e4ebb">Top 5 SQL Functions</a></p></li><li><p><a href="https://fivetran.com/blog/bucketing-in-sql">Bucketing in SQL</a> - grouping, bucketing, and segmenting users, dates, events in SQL, from simple to complex cases.&nbsp;</p></li></ul><ul><li><p><a href="https://tanelpoder.com/posts/reasons-why-select-star-is-bad-for-sql-performance/">Reasons why SELECT * is bad for SQL performance</a> - this article is more targeted towards DE, but the second part explains some good query plan optimization methods.&nbsp;</p></li><li><p><a href="https://codingsight.com/practical-use-of-sql-coalesce-function">A Practical Use of the SQL COALESCE Function</a>&nbsp;</p></li><li><p><a href="https://coffingdw.com/snowflake-analytics-part-5-mdiff/">Snowflake Analytics &#8211; Moving Difference</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/postgresql-joining-two-tables-which-are-not-related-by-a-foreign-key-relationship-a81c3504f78">Joining two tables that are not related by a foreign key relationship</a>&nbsp;</p></li><li><p><a href="https://sqlpad.io/tutorial/4-essential-sql-window-functions-and-examples-for-a-data-scientist-interview-in-2021">4 Essential SQL Window Functions</a></p></li><li><p><a href="https://hakibenita.com/sql-for-data-analysis">Practical SQL for Data Analysis</a></p></li><li><p><a href="https://statsbot.co/blog/calculating-customer-lifetime-value-sql-example/">Calculating Customer Lifetime Value: SQL Example</a></p></li><li><p><a href="https://hakibenita.com/sql-group-by-first-last-value">How to Get the First or Last Value in a Group Using Group By in SQL</a></p></li><li><p><a href="https://codingsight.com/sql-drop-table-statement-and-various-use-cases">SQL DROP TABLE Statement and Various Use Cases</a>&nbsp;</p></li><li><p><a href="https://codingsight.com/introduction-to-temporary-tables-in-sql-server/">Introduction to Temporary Tables in SQL Server</a></p></li></ul><h3><strong>&#128640; Advance and become an expert</strong>&nbsp;</h3><ul><li><p><a href="http://codingsight.com/how-to-parse-strings-like-a-pro-using-sql-substring/">How to Parse Strings Like a Pro Using SQL SUBSTRING() Function?</a></p></li><li><p><a href="https://codingsight.com/passing-data-table-as-parameter-to-stored-procedures/">Passing Data table as Parameter to Stored Procedures</a></p></li><li><p><a href="https://www.cybertec-postgresql.com/en/json-postgresql-how-to-use-it-right/">JSON IN POSTGRESQL: HOW TO USE IT RIGHT</a></p></li><li><p><a href="https://about.gitlab.com/blog/2016/03/18/fast-search-using-postgresql-trigram-indexes/">Postgres Full-Text Search</a></p></li><li><p><a href="https://mjk.space/advanced-sql-cte/">Advanced SQL - Common Table Expressions</a></p></li></ul><p>And some of my favorite publications from one and only <a href="https://dataanalysis.substack.com/p/expert-insight-haki-benita-choosing">Haki Benita</a> &#11088;:&nbsp;</p><ul><li><p><a href="https://hakibenita.com/sql-anomaly-detection">Simple Anomaly Detection Using Plain SQL</a></p></li><li><p><a href="https://hakibenita.com/python-dependency-injection">Stop Using datetime.now!</a></p></li><li><p><a href="https://hakibenita.com/sql-dos-and-donts">12 Common Mistakes and Missed Optimization Opportunities in SQL</a></p></li><li><p><a href="https://hakibenita.com/fast-load-data-python-postgresql">Fastest Way to Load Data Into PostgreSQL Using Python</a></p></li></ul><h3><strong>&#128296; Practicing SQL</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bx06!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bx06!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 424w, https://substackcdn.com/image/fetch/$s_!bx06!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 848w, https://substackcdn.com/image/fetch/$s_!bx06!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 1272w, https://substackcdn.com/image/fetch/$s_!bx06!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bx06!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png" width="1100" height="500" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/f0d4a056-847c-450d-9c14-a39209561476_2668x1212.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:500,&quot;width&quot;:1100,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:422976,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bx06!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 424w, https://substackcdn.com/image/fetch/$s_!bx06!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 848w, https://substackcdn.com/image/fetch/$s_!bx06!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 1272w, https://substackcdn.com/image/fetch/$s_!bx06!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0d4a056-847c-450d-9c14-a39209561476_2668x1212.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>The best way to practice SQL is in your local database. For this, you can install the <a href="https://www.postgresql.org/">PostgreSQL</a> database and use <a href="https://www.jetbrains.com/datagrip/">the DataGrip</a> client (free 30-day trial!) with it. This gives you the flexibility to design the schema the way you want and practice SQL from anywhere at any time.&nbsp;</p><p>If you want to go a simpler route, use <a href="http://sqlfiddle.com/">SQLFiddle</a> or <a href="https://www.db-fiddle.com/">DB-Feddle</a> tools. You can either paste your SQL there and polish the syntax or design your own table schema.&nbsp;</p><p>You can also try <a href="https://simplql.com/">Simplql</a> - an in-browser tool that lets you query data files with SQL without using a database. It does everything in the browser. Users can export the results from their queries in CSV or JSON. Easy, fast, intuitive. Love it!&nbsp;</p><h3><strong>&#127891; SQL Tutorials</strong></h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!KhFP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!KhFP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 424w, https://substackcdn.com/image/fetch/$s_!KhFP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 848w, https://substackcdn.com/image/fetch/$s_!KhFP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 1272w, https://substackcdn.com/image/fetch/$s_!KhFP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!KhFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png" width="1100" height="763" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:763,&quot;width&quot;:1100,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:297451,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!KhFP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 424w, https://substackcdn.com/image/fetch/$s_!KhFP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 848w, https://substackcdn.com/image/fetch/$s_!KhFP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 1272w, https://substackcdn.com/image/fetch/$s_!KhFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F7755eb49-884b-4668-8e0b-5aea4b8df557_1398x970.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p>If you are new to SQL and are looking for a quick tutorial on basics, check out <a href="https://sqlzoo.net/wiki/SQL_Tutorial">SQL Zoo</a>.&nbsp;</p><p><a href="https://mode.com/sql-tutorial/introduction-to-sql/">The SQL Tutorial for Data Analysis</a> - this is from Mode, so there are many CTAs around, but some descriptions are spot on and the structure is good. They also have another - <a href="https://mode.com/sql-tutorial/intro-to-intermediate-sql/">The Intermediate SQL Tutorial</a>, which is more focused on functions and joins.&nbsp;</p><p><a href="http://www.sqlcourse2.com/">SQLCourse2.com</a> - an online interactive SQL tutorial, from basics to advanced topics. Very similar to <a href="https://www.w3schools.com/sql/">W3 school SQL</a>.</p><p><a href="https://www.tutorialrepublic.com/sql-tutorial/">TutorialRepublic - SQL Tutorial</a> - I like this tutorial more, as it contains more specific examples, making it easier to understand.&nbsp;</p><p><a href="https://leetcode.com/problemset/database/">Leetcode - SQL</a> - a set of SQL problems and challenges by topic, from simple to difficult. A good source to test yourself.&nbsp;</p><p><a href="https://www.windowfunctions.com/">WindowFunctions </a>and <a href="https://www.pgcasts.com/">PG Casts</a> - more on an advanced side for SQL users. Postgres specific.&nbsp;</p><h3><strong>&#8265;&#65039; Interview preparation</strong></h3><ul><li><p><a href="https://www.interviewquery.com/blog-sql-interview-questions/">50+ SQL Interview Questions and Answers (Updated for 2021)</a></p></li><li><p><a href="https://www.interviewbit.com/sql-interview-questions/">SQL Interview Questions</a>&nbsp;</p></li></ul><div><hr></div><p>I continually update this list to keep it fresh and relevant, so please send me your favorite SQL links and sources that you think I should add!&nbsp;&nbsp;</p><p>Thanks for reading, everyone. Until next Wednesday!</p><h2>Related publications:</h2><ul><li><p><a href="https://dataanalysis.substack.com/p/sql-date-time-checklist">SQL Date-Time Cheatsheet</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/data-analysis-in-sqlite-data-formatting-casting-adcddfb0816e">SQL: Getting Started with SQLite</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-install-a-database-issue-42">How To Install A Database</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/user-activity-analysis-in-sql-issue">User Activity Analysis In SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/currency-conversion-in-sql-issue">Currency Conversion In SQL and Python</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/advanced-sql-functions-for-data-analysis">Advanced SQL Functions For Data Analysis</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/how-to-create-date-series-in-sql">How To Create Date Series in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/a-new-sql-function-qualify-and-how">A new SQL function - QUALIFY! And How To Optimize A Query Run Time</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/data-sampling-in-postgresql-b6a2a62e1e47">SQL: Data Sampling in RedShift</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/day-of-the-week-analysis-in-sql-issue">Day Of The Week Analysis in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/user-segmentation-and-power-user-analysis-in-sql-182e6c040235">User Segmentation and Power User Analysis in SQL</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/sql-hack-sql-interview-questions">SQL Interview Questions + Preparation Tips</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/sql-joins-dont-scale-issue-2">SQL Joins Don&#8217;t Scale?</a></p></li><li><p><a href="https://dataanalysis.substack.com/p/facebook-sql-interview-question-issue">Facebook SQL Interview Question</a></p></li></ul>]]></content:encoded></item><item><title><![CDATA[Facebook SQL Interview Question - Issue 63]]></title><description><![CDATA[A classic SQL interview question for a data science position at Facebook with some offered solutions]]></description><link>https://dataanalysis.substack.com/p/facebook-sql-interview-question-issue</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/facebook-sql-interview-question-issue</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 06 Oct 2021 16:30:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!aMo5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Faf0c1434-2d98-4760-af85-9eca5ed4121b_760x320.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello, data people! Today I want to share an example of a technical coding interview question for a data science position at Facebook, and offer one of the solutions for <em>solving </em>it. I&#8217;ll walk through the steps on how to best approach and break down the problem and find a solution. Data Science at Facebook is a cross-functional role, and candidates are t&#8230;</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/facebook-sql-interview-question-issue">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[A new SQL function - QUALIFY! And How To Optimize A Query Run Time - Issue 57]]></title><description><![CDATA[SQL window function QUALIFY, its use-cases, and overview of SQL optimization practice]]></description><link>https://dataanalysis.substack.com/p/a-new-sql-function-qualify-and-how</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/a-new-sql-function-qualify-and-how</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 18 Aug 2021 16:30:16 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!nASj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hot off the presses, here&#8217;s a new fancy SQL function for your enjoyment today - QUALIFY.&nbsp;</p><p>To be fair, this function is not new and has been around for ages, originally coming from Teradata and available today in Oracle and Snowflake. I just happened to discover it this week while dealing with a Snowflake SQL problem and it blew my mind! This allows you to do complex aggregations while significantly reducing query run time.</p><p>In this issue, I&#8217;ll demonstrate an example of how QUALIFY helps you optimize your SQL, how it is better than HAVING, and go over some SQL cost/time optimization challenges.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!JW0w!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!JW0w!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!JW0w!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!JW0w!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!JW0w!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!JW0w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png" width="200" height="200" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:200,&quot;width&quot;:200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!JW0w!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 424w, https://substackcdn.com/image/fetch/$s_!JW0w!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 848w, https://substackcdn.com/image/fetch/$s_!JW0w!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 1272w, https://substackcdn.com/image/fetch/$s_!JW0w!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F4631b615-eaa4-4ec7-a26e-c179b03bdd41_200x200.png 1456w" sizes="100vw" fetchpriority="high"></picture><div></div></div></a></figure></div><h3><strong>How QUALIFY works</strong></h3><p>To start with, QUALIFY is very similar to HAVING and WHERE and simply filters further ordered rows or performs aggregations. The main difference between QUALIFY and HAVING is that the former filters multiple ordered functions. It allows the execution of complex window functions without affecting query run time.</p><h3><strong>Examples&nbsp;</strong></h3><p>Before I learned about QUALIFY, I&#8217;d normally create a window function (like ROW_NUMBER or RANK) in a subquery which I&#8217;d call in a WHERE clause in the upper query to filter records. Like I did in the <a href="https://dataanalysis.substack.com/p/user-activity-analysis-in-sql-issue">User Activity Analysis</a> in <a href="https://gist.github.com/ks--ks/04684a307310a2d3647496dc41639482">this SQL</a>, I used the RANK() window function to locate the most popular user activity across all users.&nbsp;</p><p>Or in another example, let&#8217;s say I want to locate the top payer in my user base segmented by product type. Here is one way to do it using a subquery and ROW_NUMBER() function:&nbsp;</p><pre><code><code>SELECT product_type, user_id, paid_price
from (
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SELECT product_type,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#9;&#9;user_id,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ROW_NUMBER() OVER (PARTITION BY product_type ORDER BY paid_price DESC) AS row_num,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DISPLAY_PRICE
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM users
 )
WHERE row_num = 1</code></code></pre><p>You can simply this logic a lot by applying QUALIFY which would transform the query to:</p><pre><code>SELECT product_type,
user_id,
paid_price
FROM users
QUALIFY ROW_NUMBER() OVER (PARTITION BY product_type ORDER BY paid_price DESC) = 1</code></pre><p>This query does the same job as the previous one, but is more optimal for the cost and execution time.&nbsp;</p><h3><strong>SQL optimization methods</strong></h3><p>Optimizing query performance time is important and demonstrates your knowledge of RDBS. SQL optimization techniques are my favorite interview questions, especially at small companies where every analyst has access to a production database and has the freedom to run any SELECT queries. Slow or failing SQL queries may cause more damage and slow down whole database performance or reduce its efficiency.&nbsp;</p><p>While SQL tuning is more a data engineering topic, every analyst must have an understanding of how indexes work and know basic and simple query optimization techniques. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nASj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nASj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 424w, https://substackcdn.com/image/fetch/$s_!nASj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 848w, https://substackcdn.com/image/fetch/$s_!nASj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!nASj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nASj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg" width="1280" height="720" data-attrs="{&quot;src&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/fa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:720,&quot;width&quot;:1280,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:106421,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nASj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 424w, https://substackcdn.com/image/fetch/$s_!nASj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 848w, https://substackcdn.com/image/fetch/$s_!nASj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!nASj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa5f69dc-a23d-4aba-b1cf-db2bdf99d950_1280x720.jpeg 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a></figure></div><p><em>Taken from <a href="https://www.youtube.com/watch?v=YuRO9-rOgv4">YouTube video - How do SQL Indexes Work</a>, one of the best index explanations I have come across.</em></p><p>If you are asked during your interview about best practices of query optimizations, this is what you should mention:&nbsp;</p><ol><li><p>Avoid use SELECT * but rather list the columns you need</p></li><li><p>Avoid SELECT DISTINCT if you can</p></li><li><p>Apply filter with WHERE and not HAVING</p></li><li><p>Use LIMIT to cup your query results</p></li><li><p>Avoid using sub-queries&nbsp;</p></li><li><p>Avoid using OUTER JOINs</p></li><li><p>Avoid using cross joins (which are the most expensive)&nbsp;</p></li></ol><p>If you are a data engineer or DBA, I would expect you to be able to explain the logic behind these.&nbsp;</p><h3><strong>How QUALIFY function helps optimize SQL</strong></h3><p>As of now, SQL allows window calculations only in the SELECT (and ORDER BY in some SQL variations). This means that window functions are evaluated after the FROM, WHERE, GROUP BY, and HAVING clauses. You can use a subquery to perform needed filtering (as I did in my first example), however, this adds a layer of complexity to the execution time and cost. QUALIFY allows referring to window calculations directly without the need for a table expression.</p><p>This is how SELECT statement execution order works:</p><ol><li><p>FROM</p></li><li><p>WHERE</p></li><li><p>GROUP BY</p></li><li><p>HAVING</p></li><li><p>SELECT</p></li><li><p>ORDER BY</p></li></ol><p>This explains why HAVING is more costly than WHERE, and why window functions in the SELECT are more expensive than using QUALIFY because of the latter acting like WHERE or HAVING.&nbsp;</p><div><hr></div><p>While these are all useful features, the bad news is that QUALIFY is available only in Snowflake and Oracle now (and Teradata). In Postgres or SQLserver you would still need to apply alternative solutions like aggregates and a subquery. However, I imagine that this will all be integrated before too long, and this function will be supported everywhere.&nbsp;</p><p>Here are links to the original QUALIFY documentation:&nbsp;&nbsp;&nbsp;</p><p><a href="https://docs.snowflake.com/en/sql-reference/constructs/qualify.html">Qualify in Snowflake</a></p><p><a href="https://docs.oracle.com/cd/E57185_01/HIRUG/ch12s04s04s09.html">Qualify function in Oracle</a></p><p>Thanks for reading, everyone. Until next Wednesday!</p>]]></content:encoded></item><item><title><![CDATA[Advanced SQL Functions For Data Analysis - Issue 47]]></title><description><![CDATA[Building complex and advanced SQL queries for data analysis, data manipulation, and modeling]]></description><link>https://dataanalysis.substack.com/p/advanced-sql-functions-for-data-analysis</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/advanced-sql-functions-for-data-analysis</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 09 Jun 2021 16:30:42 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!JHSz!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F9578884c-f72a-4b8d-b7d9-6406b1fb3af0_4226x2950.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>SQL is the most required skill for data analysis, data science, and data engineering. It&#8217;s easy to pick up and learn, but it also takes time, perseverance, and persistence to progress to an advanced level. About 80% of analysts who are out there ...analyzing (I mean, what <em>else </em>would they be doing?) use mostly basic SQL, while only 20% master it and take&#8230;</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/advanced-sql-functions-for-data-analysis">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[How To Install A Database - Issue 42]]></title><description><![CDATA[Learn how to install a database and practice SQL on your own to nail take-home assignments and interview questions]]></description><link>https://dataanalysis.substack.com/p/how-to-install-a-database-issue-42</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/how-to-install-a-database-issue-42</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 05 May 2021 16:30:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!KCPJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F17317232-fba0-4760-896d-cd2b9d50e1ee_730x920.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever received a take-home assignment to write a SQL query to solve a problem? Did you break your brain over how to install a database, replicate a table with a sample of data (that is usually not provided) and test your SQL? I did. Back then when I was young and foolish. After many hours of figuring that out, I can now share with you the logic &#8230;</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/how-to-install-a-database-issue-42">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[Day Of The Week Analysis in SQL - Issue 39]]></title><description><![CDATA[How to break down user activity by day of the week in SQL. Simple to pull, takes a few minutes to write the query, and data is easy to interpret and present.]]></description><link>https://dataanalysis.substack.com/p/day-of-the-week-analysis-in-sql-issue</link><guid isPermaLink="false">https://dataanalysis.substack.com/p/day-of-the-week-analysis-in-sql-issue</guid><dc:creator><![CDATA[Olga Berezovsky]]></dc:creator><pubDate>Wed, 14 Apr 2021 16:30:10 GMT</pubDate><enclosure url="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/c532c34b-332b-4a0f-a45a-4d8d1ba69f1d_948x846.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone! Today&#8217;s topic is a SQL solution for one of my favorite quick data explorations - <strong>weekday usage analysis </strong>(also known as DOW analysis - day of the week). I often run it as the first query working on a new dataset - breaking user actions down on days of the week.&nbsp;</p><p>It&#8217;s my favorite because it&#8217;s simple to pull, literally takes a few minutes to write the query, and the data is easy to interpret and present. At the same time, it opens a virtual universe of insight into the business type, lifecycle, and user behavior. It helps to answer questions like:&nbsp;</p><ul><li><p>Does the business have cyclicality?&nbsp;</p></li><li><p>If yes, what does it look like? When does the largest volume of activity happen? Is it a complete pattern?&nbsp;</p></li><li><p>What sort of impact do holidays and weekends create?&nbsp;</p></li><li><p>How does user acquisition work?&nbsp;</p></li><li><p>What % of paid traffic drives signups?&nbsp;</p></li><li><p>How do conversion funnels work?&nbsp;</p></li></ul><p>All of this and more. Weekday usage analysis provides a segway into exploring user activity and answering the questions above. Below, I&#8217;ll share SQL code and my approach to exploring the activity pattern.</p>
      <p>
          <a href="https://dataanalysis.substack.com/p/day-of-the-week-analysis-in-sql-issue">
              Read more
          </a>
      </p>
   ]]></content:encoded></item></channel></rss>