<?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[dat-a-man — Data with Aman: Blog]]></title><description><![CDATA[Research-Reflect-Simplify-Share.]]></description><link>https://www.dataman.blog/s/blogs</link><image><url>https://substackcdn.com/image/fetch/$s_!Dbyi!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F840e7a4d-3613-42c8-857e-6e0253c7d041_1024x1024.png</url><title>dat-a-man — Data with Aman: Blog</title><link>https://www.dataman.blog/s/blogs</link></image><generator>Substack</generator><lastBuildDate>Sat, 11 Apr 2026 04:51:55 GMT</lastBuildDate><atom:link href="https://www.dataman.blog/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Aman Gupta]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[adatayogi@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[adatayogi@substack.com]]></itunes:email><itunes:name><![CDATA[Aman Gupta]]></itunes:name></itunes:owner><itunes:author><![CDATA[Aman Gupta]]></itunes:author><googleplay:owner><![CDATA[adatayogi@substack.com]]></googleplay:owner><googleplay:email><![CDATA[adatayogi@substack.com]]></googleplay:email><googleplay:author><![CDATA[Aman Gupta]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Dimensional Modeling: The 30-Year-Old Idea Every Modern Data Engineer Still Needs”]]></title><description><![CDATA[The architecture behind every great data stack proven, practical, and built to last.]]></description><link>https://www.dataman.blog/p/dimensional-modeling-the-30-year</link><guid isPermaLink="false">https://www.dataman.blog/p/dimensional-modeling-the-30-year</guid><dc:creator><![CDATA[Aman Gupta]]></dc:creator><pubDate>Tue, 11 Nov 2025 05:30:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!QxQw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QxQw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QxQw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!QxQw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!QxQw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!QxQw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QxQw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2723683,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!QxQw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!QxQw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!QxQw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!QxQw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3020fb29-108b-49e0-9793-9171c9dc8a90_1536x1024.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><h2>1). &#8220;<strong>The irony of data: built for speed, stuck in traffic.&#8221;</strong></h2><blockquote><p>&#8220;Data&#8217;s a trend-chaser. First a warehouse, then a lake, now a lakehouse. But behind the buzzwords, it&#8217;s always chasing the same thing: `<strong>CLARITY</strong>`.&#8221;</p></blockquote><p>Data&#8217;s like that seasoned pro who&#8217;s seen every fad come and go, warehouse, lake, lakehouse, whatever&#8217;s next.</p><p>It doesn&#8217;t need a rebrand to stay relevant because it&#8217;s still solving the same timeless puzzle: making chaos make sense.</p><p>Humans, queries, entire companies still rely on it to turn raw noise into reason.</p><p>So , it&#8217;s old, but like vinyl or good coffee, that&#8217;s exactly why it never goes out of style.</p><div><hr></div><h2>2). The problem: today&#8217;s data chaos hiding inside modern warehouses.</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1pKG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1pKG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!1pKG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!1pKG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!1pKG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1pKG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3831578,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1pKG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!1pKG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!1pKG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!1pKG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F855ff632-9eef-48ae-bbc4-476bb571a6d3_1536x1024.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>&#8220;Modern context&#8221; in very easy words means <strong>how something fits or makes sense in today&#8217;s world,</strong> not in the past.</p><p>When we say &#8220;in the modern context,&#8221; it means we are looking at something based on how people live, think, and use new ideas and technology today. It&#8217;s about understanding how things fit in our present time, not how they were in the past.</p><p><strong>Example:</strong></p><p>In the past, very few women worked outside the home. But today, in the modern context, women have jobs and build careers. So society&#8217;s idea of women&#8217;s roles has changed to fit modern life.</p><h3>Cloud warehouses made data cheap and fast &#8594; so people just started to dump everything in them.</h3><p><strong>The magnitude of data has exploded ; especially after 2020</strong>.</p><p>In 2020, the world generated around 64.2 zettabytes of data that&#8217;s 64.2 trillion gigabytes. Since then, global data creation has surged exponentially, fueled by the rise of AI, IoT, remote work, and digital media. By 2025, projections from DemandSage and Seagate estimate total data generation will reach 181 zettabytes nearly three times what it was in 2020, growing at an average rate of 22&#8211;26% per year.</p><p>Cloud data warehouses made storing all this information cheap, fast, and scalable, leading many organizations to adopt a &#8220;dump everything&#8221; mindset pouring every dataset into the warehouse without much structure or strategy. While this worked at first, it quickly created chaos: hundreds of tables, unclear relationships, and multiple conflicting versions of key metrics like &#8220;revenue.&#8221;</p><p>Without proper cleaning, validation, or governance, data becomes cluttered, slow to query, and hard to trust.</p><blockquote><p>It&#8217;s like blending all your groceries together and calling it dinner technically everything&#8217;s there, but nobody wants to touch it.</p></blockquote><p>The result is data overload, slower performance, and unreliable insights proving that even in an age of infinite storage, organized data still wins.</p><p><strong>Graphical representation:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3hPL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3hPL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 424w, https://substackcdn.com/image/fetch/$s_!3hPL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 848w, https://substackcdn.com/image/fetch/$s_!3hPL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!3hPL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3hPL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png" width="1456" height="957" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:957,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:162022,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3hPL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 424w, https://substackcdn.com/image/fetch/$s_!3hPL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 848w, https://substackcdn.com/image/fetch/$s_!3hPL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!3hPL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3d039cde-0821-47ad-8df8-9c41d065a7b7_2170x1426.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><h3>Emphasize the pain:</h3><ul><li><p>Analysts don&#8217;t trust dashboards because the data behind them is messy or wrong, leading to incorrect insights.</p></li><li><p>Metrics don&#8217;t match across reports or tables, making it impossible to know which numbers are true.</p></li><li><p>Queries take forever to run since the system is overloaded with unorganized, duplicated, or conflicting data.</p></li></ul><h3>Humour:</h3><blockquote><p>&#8220;If you&#8217;ve ever joined five tables just to figure out who bought what, welcome to the world of data wrestling , where dimensional modeling is the referee that stops the chaos and declares a clear winner!&#8221;</p></blockquote><div><hr></div><h2>3). The promise: A way to make data actually make sense.</h2><p>Dimensional modeling is the proven way to structure data so anyone, not just engineers, can navigate it confidently and get clear, reliable answers to real business questions.</p><h3>It is based on two core ideas:</h3><ol><li><p><strong>Facts:</strong> These are the important numbers or measurements in your business, like sales amount, number of units sold, or revenue. Facts represent what you want to measure or analyze.</p></li><li><p><strong>Dimensions:</strong> These are the descriptive details or context about the facts, such as time (day, month, year), product (name, category), customer (age, location), or store. Dimensions help you answer questions like &#8220;When was it sold?&#8221; or &#8220;Who bought it?&#8221; or &#8220;Where was it sold?&#8221;</p></li></ol><p>The fact tables hold the measurable data, while the dimension tables hold the descriptive information.</p><p>By organizing data into facts and dimensions, dimensional modeling improves data retrieval speed, clarity, and usability in data warehouses</p><h3>Simple visual example student_attendence</h3><p>Captures the measurable event: a student attending a class.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!agYy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!agYy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 424w, https://substackcdn.com/image/fetch/$s_!agYy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 848w, https://substackcdn.com/image/fetch/$s_!agYy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 1272w, https://substackcdn.com/image/fetch/$s_!agYy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!agYy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png" width="1230" height="292" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:292,&quot;width&quot;:1230,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:49166,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!agYy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 424w, https://substackcdn.com/image/fetch/$s_!agYy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 848w, https://substackcdn.com/image/fetch/$s_!agYy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 1272w, https://substackcdn.com/image/fetch/$s_!agYy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb8b0306f-aa74-4407-b73f-030054053d0a_1230x292.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>&#9989; <strong>Fact table</strong> = the event itself (<em>who attended what, when, and for how long</em>). It stores numeric or measurable data.</p><h3>Dimension Table &#8211; <code>students</code></h3><p>Describes who attended.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!o9jb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!o9jb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 424w, https://substackcdn.com/image/fetch/$s_!o9jb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 848w, https://substackcdn.com/image/fetch/$s_!o9jb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 1272w, https://substackcdn.com/image/fetch/$s_!o9jb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!o9jb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png" width="1018" height="278" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:278,&quot;width&quot;:1018,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:52638,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!o9jb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 424w, https://substackcdn.com/image/fetch/$s_!o9jb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 848w, https://substackcdn.com/image/fetch/$s_!o9jb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.png 1272w, https://substackcdn.com/image/fetch/$s_!o9jb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff5100e11-214d-4f87-bf0f-dec87099c92c_1018x278.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><h3>&#128218; Dimension Table &#8211; <code>courses</code></h3><p>Describes what they attended.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!8Bhg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Bhg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 424w, https://substackcdn.com/image/fetch/$s_!8Bhg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 848w, https://substackcdn.com/image/fetch/$s_!8Bhg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 1272w, https://substackcdn.com/image/fetch/$s_!8Bhg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Bhg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png" width="1030" height="290" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:290,&quot;width&quot;:1030,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:51039,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8Bhg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 424w, https://substackcdn.com/image/fetch/$s_!8Bhg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 848w, https://substackcdn.com/image/fetch/$s_!8Bhg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.png 1272w, https://substackcdn.com/image/fetch/$s_!8Bhg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd37db54e-cdf5-455c-81e9-82af07b74000_1030x290.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><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XG1b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XG1b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!XG1b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!XG1b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!XG1b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XG1b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/aed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2660823,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!XG1b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!XG1b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!XG1b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!XG1b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faed5cda9-3a17-4127-bd30-42a490ad24e8_1536x1024.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><h3>&#128279; <strong>Relationships:</strong></h3><ul><li><p><code>student_attendance.student_id</code> &#8594; <code>students.student_id</code></p></li><li><p><code>student_attendance.course_id</code> &#8594; <code>courses.course_id</code></p></li></ul><p><strong>In simple terms:</strong></p><ul><li><p><strong>Fact table</strong> = the measurable event (attendance).</p></li><li><p><strong>Dimension tables</strong> = the descriptive context (who the student is, what course they attended).</p></li></ul><blockquote><p>&#8220;Trying to analyze data without dimensional modeling is like trying to untangle Christmas lights frustrating, time-consuming, and making you wonder if you should just buy a new set!&#8221;</p></blockquote><div><hr></div><h2><strong>4. &#8220;Why it still matters ; even in the age of dbt and the modern data stack&#8221;.</strong></h2><p>Because tools like dbt, Airflow, and the rest of the modern data stack are powerful , but they don&#8217;t replace the need for good modeling, they just automate and scale it.</p><h3>Dimensional modeling still matters because:</h3><ul><li><p><strong>Supports modern tools:</strong> dbt, metrics layers, and BI platforms still rely on a solid data model underneath to work effectively.</p></li><li><p><strong>Scales with complexity:</strong> As data grows and evolves, a dimensional model keeps queries simple and performance predictable.</p></li><li><p><strong>Timeless foundation:</strong> Technologies change, but the need for clarity, consistency, and context in analytics never does.</p></li></ul><blockquote><p>It&#8217;s the difference between following a clear path and getting lost without a clue where to go.</p></blockquote><div><hr></div><h2>5. The myth: &#8220;Isn&#8217;t a data lake enough?&#8221;</h2><blockquote><p>&#8220;Sure, you can run analytics directly on raw JSON files in S3, if you&#8217;re okay with messy queries, slow results, and a lot of confusion every time you need an answer.&#8221;</p></blockquote><p>Just storing all your data in one place (like a data lake in S3) doesn&#8217;t mean it&#8217;s ready to use. That&#8217;s like having all the ingredients for a cake but no recipe, the pieces are there, but they&#8217;re not useful yet.</p><p>Sure, you <em>can</em> run analytics directly on messy raw JSON files in S3, but you&#8217;ll end up with confusing queries, slow results, and numbers that don&#8217;t match from one dashboard to another.</p><p>That&#8217;s where <strong>modeling</strong> comes in. It&#8217;s the process of organizing and structuring your data so it&#8217;s clear, consistent, and easy to work with.</p><h3>Once you model your data:</h3><ul><li><p>Metrics stay consistent &#8212; everyone agrees on what &#8220;active user&#8221; or &#8220;revenue&#8221; means.</p></li><li><p>Queries run faster &#8212; because the data is organized and optimized.</p></li><li><p>New people can understand the data quickly &#8212; because there&#8217;s a clear structure.</p></li></ul><p><strong>Key idea:</strong> Tools will always change, but the basic principle of organizing your data so humans (and machines) can understand it will never stop being important.</p><div><hr></div><h2>6. Example: online retail store</h2><p>&#8220;Think of an online retail store managing thousands of daily orders. The <strong>fact table</strong> records each sale, what was sold, who bought it, where, and when. The <strong>dimension tables</strong> add meaning: products describe what was sold, customers tell who bought it, stores show where it happened, and time shows when. With this setup, the business can quickly ask questions like &#8216;Which region generated the most revenue this month?&#8217; or &#8216;Which product categories are gaining popularity over time?</p><p><strong>Step 1: Create Tables</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lOdX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lOdX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 424w, https://substackcdn.com/image/fetch/$s_!lOdX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 848w, https://substackcdn.com/image/fetch/$s_!lOdX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 1272w, https://substackcdn.com/image/fetch/$s_!lOdX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lOdX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png" width="1456" height="1971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:501988,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lOdX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 424w, https://substackcdn.com/image/fetch/$s_!lOdX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 848w, https://substackcdn.com/image/fetch/$s_!lOdX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.png 1272w, https://substackcdn.com/image/fetch/$s_!lOdX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F35da3344-e1bf-4a8f-a57e-4de6b9bb5bf5_2376x3216.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><strong>Step 2: Insert Sample Data</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!k1kG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!k1kG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 424w, https://substackcdn.com/image/fetch/$s_!k1kG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 848w, https://substackcdn.com/image/fetch/$s_!k1kG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 1272w, https://substackcdn.com/image/fetch/$s_!k1kG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!k1kG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png" width="1456" height="1697" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/41871771-1203-401a-a29d-017540921bdb_2080x2424.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1697,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:413322,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!k1kG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 424w, https://substackcdn.com/image/fetch/$s_!k1kG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 848w, https://substackcdn.com/image/fetch/$s_!k1kG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.png 1272w, https://substackcdn.com/image/fetch/$s_!k1kG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F41871771-1203-401a-a29d-017540921bdb_2080x2424.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><strong>Step 3: Query to Generate Result</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!w2vR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!w2vR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 424w, https://substackcdn.com/image/fetch/$s_!w2vR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 848w, https://substackcdn.com/image/fetch/$s_!w2vR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 1272w, https://substackcdn.com/image/fetch/$s_!w2vR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!w2vR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png" width="1456" height="909" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:909,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:193819,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!w2vR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 424w, https://substackcdn.com/image/fetch/$s_!w2vR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 848w, https://substackcdn.com/image/fetch/$s_!w2vR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.png 1272w, https://substackcdn.com/image/fetch/$s_!w2vR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F83f0b283-487b-46eb-b08e-617f2712bc10_2192x1368.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><strong>Then output:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EzEr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EzEr!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 424w, https://substackcdn.com/image/fetch/$s_!EzEr!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 848w, https://substackcdn.com/image/fetch/$s_!EzEr!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 1272w, https://substackcdn.com/image/fetch/$s_!EzEr!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EzEr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png" width="1038" height="354" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:354,&quot;width&quot;:1038,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:61431,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EzEr!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 424w, https://substackcdn.com/image/fetch/$s_!EzEr!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 848w, https://substackcdn.com/image/fetch/$s_!EzEr!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.png 1272w, https://substackcdn.com/image/fetch/$s_!EzEr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bbec505-6864-47be-a46a-6b4fd4dd1f66_1038x354.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>This complete query sequence, from start to end models customer purchases cleanly, showcasing how the fact table logs each order and the dimension tables describe who, what, and when.</p><h3>Show how this model powers metrics:</h3><ul><li><p>&#8220;Want monthly revenue by region? Easy aggregate sales by time and region dimensions.&#8221;</p></li><li><p>&#8220;Want retention by customer type? Join facts to the customer dimension.&#8221;</p></li></ul><p><strong>1. Monthly Revenue by Region:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rmN5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rmN5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 424w, https://substackcdn.com/image/fetch/$s_!rmN5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 848w, https://substackcdn.com/image/fetch/$s_!rmN5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 1272w, https://substackcdn.com/image/fetch/$s_!rmN5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rmN5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png" width="1456" height="708" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:708,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2093260,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rmN5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 424w, https://substackcdn.com/image/fetch/$s_!rmN5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 848w, https://substackcdn.com/image/fetch/$s_!rmN5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.png 1272w, https://substackcdn.com/image/fetch/$s_!rmN5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96d59210-aeb6-494a-a9db-b0cb9305cd35_2632x1280.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><strong>Output:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wrAO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wrAO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 424w, https://substackcdn.com/image/fetch/$s_!wrAO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 848w, https://substackcdn.com/image/fetch/$s_!wrAO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 1272w, https://substackcdn.com/image/fetch/$s_!wrAO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wrAO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png" width="734" height="246" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:246,&quot;width&quot;:734,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:31263,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wrAO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 424w, https://substackcdn.com/image/fetch/$s_!wrAO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 848w, https://substackcdn.com/image/fetch/$s_!wrAO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.png 1272w, https://substackcdn.com/image/fetch/$s_!wrAO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91591601-8b18-4c1a-bc81-f77b398fe82c_734x246.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><strong>Graph:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!aFOK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!aFOK!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 424w, https://substackcdn.com/image/fetch/$s_!aFOK!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 848w, https://substackcdn.com/image/fetch/$s_!aFOK!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!aFOK!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!aFOK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png" width="1456" height="957" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:957,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:185775,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!aFOK!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 424w, https://substackcdn.com/image/fetch/$s_!aFOK!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 848w, https://substackcdn.com/image/fetch/$s_!aFOK!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!aFOK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa40ebc9d-bc8a-49e2-84b9-db77e4d14b0c_2170x1426.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><strong>2. Retention by Customer Type:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!AyF1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!AyF1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 424w, https://substackcdn.com/image/fetch/$s_!AyF1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 848w, https://substackcdn.com/image/fetch/$s_!AyF1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!AyF1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!AyF1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png" width="1456" height="792" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:792,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:186564,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!AyF1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 424w, https://substackcdn.com/image/fetch/$s_!AyF1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 848w, https://substackcdn.com/image/fetch/$s_!AyF1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.png 1272w, https://substackcdn.com/image/fetch/$s_!AyF1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fff19fb7d-40cf-4d52-9925-a3ae0cb3cf18_2192x1192.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><strong>Output:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lJD7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lJD7!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 424w, https://substackcdn.com/image/fetch/$s_!lJD7!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 848w, https://substackcdn.com/image/fetch/$s_!lJD7!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 1272w, https://substackcdn.com/image/fetch/$s_!lJD7!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lJD7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png" width="1056" height="308" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:308,&quot;width&quot;:1056,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:95651,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!lJD7!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 424w, https://substackcdn.com/image/fetch/$s_!lJD7!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 848w, https://substackcdn.com/image/fetch/$s_!lJD7!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.png 1272w, https://substackcdn.com/image/fetch/$s_!lJD7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f6e5bc-9bbe-4362-b3fe-92b596a850b4_1056x308.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><strong>Graph:</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ehGf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ehGf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 424w, https://substackcdn.com/image/fetch/$s_!ehGf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 848w, https://substackcdn.com/image/fetch/$s_!ehGf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!ehGf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ehGf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png" width="1456" height="957" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:957,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137028,&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;:&quot;https://www.dataman.blog/i/178153841?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ehGf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 424w, https://substackcdn.com/image/fetch/$s_!ehGf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 848w, https://substackcdn.com/image/fetch/$s_!ehGf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!ehGf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b5f7c4d-1f64-4858-bbd4-98aad913dd2b_2170x1426.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><h3>&#8220;Add a key takeaway&#8221;:</h3><blockquote><p>&#8220;Good modeling turns technical structure into business clarity; everyone speaks the same data language.&#8221;</p></blockquote><div><hr></div><h2>7.<strong>&#8220;Final reflection: What&#8217;s Next&#8221;</strong></h2><h3><strong>Key Takeaways:</strong></h3><ul><li><p>Dimensional modeling is all about <strong>clarity.</strong></p></li><li><p>It streamlines SQL, strengthens metric accuracy, and turns dashboards into tools you&#8217;re actually proud to share.</p></li></ul><p>Structured data models do more than organize information they build <strong>trust and consistency</strong> across every report. Facts capture what happens; dimensions explain <strong>why</strong> and <strong>where</strong> it happens. Together, they turn raw data into clear, actionable insight.</p><p><strong>Up Next:</strong></p><p>In our next blog, we&#8217;ll meet the true stars of the analytics world <strong>facts and dimensions tables</strong> and learn how to tell them apart.</p><p></p><div><hr></div><p></p>]]></content:encoded></item><item><title><![CDATA[Advanced SQL Techniques: Grouping Sets, Rollups, and Self Joins”(Deep dive)]]></title><description><![CDATA[Write cleaner, smarter SQL with Grouping Sets, Rollups, and Self Joins.]]></description><link>https://www.dataman.blog/p/advanced-sql-techniques-grouping</link><guid isPermaLink="false">https://www.dataman.blog/p/advanced-sql-techniques-grouping</guid><dc:creator><![CDATA[Aman Gupta]]></dc:creator><pubDate>Tue, 30 Sep 2025 15:22:45 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!_vqk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p></p><h2>1. Introduction:</h2><h3>SQL: not just SELECT, meet the power tools you forgot existed</h3><p>SQL isn&#8217;t just about pulling rows with a simple <strong>SELECT *</strong>. It&#8217;s a language packed with hidden features that can make your queries sharper, faster, and far more expressive. Beyond the basics, SQL offers advanced capabilities like Grouping Sets, Rollups, and Self Joins , tools that many developers overlook, but which can completely change how you approach reporting and analysis. Once you know how to use them, you&#8217;ll find yourself solving problems more effectively and writing queries that do far more with less code.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_vqk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_vqk!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!_vqk!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!_vqk!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!_vqk!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_vqk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&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_!_vqk!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!_vqk!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!_vqk!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!_vqk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97ddc198-6ab7-412d-94c6-7a5623c94c0d_1024x1024.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><div><hr></div><h2>2. Foundations: why not just GROUP BY?</h2><p>Before we get into the advanced stuff, let&#8217;s take a quick refresher. <strong>GROUP BY</strong> is where most SQL users start when they need summaries.It collapses rows, applies aggregates, and gets you answers fast, totals by region, averages by customer, counts by category.</p><h3>The problem</h3><blockquote><p><code>GROUP BY</code> answers <strong>one question at a time</strong>. </p></blockquote><p>if you need totals by region, by product, and the overall total, you end up writing (and maintaining) three queries, or gluing them with<strong> UNION ALL.</strong></p><p>That&#8217;s where <strong>Grouping Sets, Rollups, and Self Joins</strong> come in. They&#8217;re designed to move you past single-level aggregations, so you can capture multiple perspectives, richer breakdowns, and even relational insights, all without writing query after query.</p><div><hr></div><h2>3. Grouping sets: multiple summaries in one query</h2><p><strong>Grouping Sets</strong> are like having multiple  <strong>GROUP BY</strong> clauses rolled into a single query. Instead of writing and unioning separate aggregations, you tell SQL exactly which &#8220;buckets&#8221; you care about, and it returns them all at once.</p><h3>Example: one query instead of three</h3><p>Say you want <strong>sales totals</strong>:</p><ol><li><p>By country</p></li><li><p>By product</p></li><li><p>Overall total</p></li></ol><p>With plain <code>GROUP BY</code>, you&#8217;d have to write three separate queries and glue them with <code>UNION ALL</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9X63!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9X63!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 424w, https://substackcdn.com/image/fetch/$s_!9X63!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 848w, https://substackcdn.com/image/fetch/$s_!9X63!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 1272w, https://substackcdn.com/image/fetch/$s_!9X63!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9X63!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png" width="1456" height="1054" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1054,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4266289,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!9X63!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 424w, https://substackcdn.com/image/fetch/$s_!9X63!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 848w, https://substackcdn.com/image/fetch/$s_!9X63!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.png 1272w, https://substackcdn.com/image/fetch/$s_!9X63!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb3b3db43-1ef8-44ce-91c5-ec04928d699a_3104x2248.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></p><p>With <strong>Grouping Sets</strong>, it&#8217;s one clean query:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!HPnF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!HPnF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 424w, https://substackcdn.com/image/fetch/$s_!HPnF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 848w, https://substackcdn.com/image/fetch/$s_!HPnF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 1272w, https://substackcdn.com/image/fetch/$s_!HPnF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!HPnF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png" width="1456" height="1104" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1104,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2510802,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!HPnF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 424w, https://substackcdn.com/image/fetch/$s_!HPnF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 848w, https://substackcdn.com/image/fetch/$s_!HPnF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.png 1272w, https://substackcdn.com/image/fetch/$s_!HPnF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2414d34e-3a27-4864-a984-7ca8147c1ca3_2268x1720.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></p><h3>output:</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3o__!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3o__!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 424w, https://substackcdn.com/image/fetch/$s_!3o__!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 848w, https://substackcdn.com/image/fetch/$s_!3o__!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 1272w, https://substackcdn.com/image/fetch/$s_!3o__!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3o__!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png" width="487" height="393.85792349726773" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:592,&quot;width&quot;:732,&quot;resizeWidth&quot;:487,&quot;bytes&quot;:60053,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3o__!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 424w, https://substackcdn.com/image/fetch/$s_!3o__!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 848w, https://substackcdn.com/image/fetch/$s_!3o__!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.png 1272w, https://substackcdn.com/image/fetch/$s_!3o__!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2cf3b7ad-5727-44ee-9edf-f5308b8d94c5_732x592.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>&#9989; <strong>Result:</strong> You get all three aggregations in a single result set, no unions, no duplicate queries.</p><h3>When to use grouping sets:</h3><ul><li><p><strong>Dashboards</strong> &#8594; where you want country-level, product-level, and global KPIs all pulled at once.</p></li><li><p><strong>Reports</strong> &#8594; monthly or quarterly summaries that combine different aggregation levels side by side.</p></li><li><p><strong>Multi-level summaries</strong> &#8594; subtotals, grand totals, and detailed breakdowns generated in one pass.</p><h3>In short:</h3><p>Anytime you find yourself writing <strong>the same SUM or COUNT three different ways</strong>, Grouping Sets can probably collapse it into a single, elegant query.</p></li></ul><div><hr></div><h2>4. Rollups</h2><h3>What Are rollups?</h3><p>A <strong>Rollup</strong> is a GROUP BY shortcut that creates <strong>progressive subtotals</strong> along a hierarchy. You give SQL an ordered list of columns, and it automatically returns results at every level, from the most detailed grouping down to the grand total.</p><h3>Example: website traffic by date</h3><p>Suppose you&#8217;re analyzing website visits and want to see:</p><ul><li><p>Visits by <strong>year and month</strong></p></li><li><p>Visits by <strong>year</strong></p></li><li><p>The overall <strong>total</strong></p></li></ul><p>You can do this with a single query using <code>ROLLUP</code>:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!dog4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!dog4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 424w, https://substackcdn.com/image/fetch/$s_!dog4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 848w, https://substackcdn.com/image/fetch/$s_!dog4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 1272w, https://substackcdn.com/image/fetch/$s_!dog4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!dog4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png" width="654" height="1418" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1418,&quot;width&quot;:654,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:615307,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!dog4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 424w, https://substackcdn.com/image/fetch/$s_!dog4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 848w, https://substackcdn.com/image/fetch/$s_!dog4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.png 1272w, https://substackcdn.com/image/fetch/$s_!dog4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff3c1607e-4d83-4ee4-93ea-3e9165b85878_654x1418.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><h3>output:</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wYnv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wYnv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 424w, https://substackcdn.com/image/fetch/$s_!wYnv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 848w, https://substackcdn.com/image/fetch/$s_!wYnv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 1272w, https://substackcdn.com/image/fetch/$s_!wYnv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wYnv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png" width="597" height="270.515625" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:580,&quot;width&quot;:1280,&quot;resizeWidth&quot;:597,&quot;bytes&quot;:60750,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!wYnv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 424w, https://substackcdn.com/image/fetch/$s_!wYnv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 848w, https://substackcdn.com/image/fetch/$s_!wYnv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.png 1272w, https://substackcdn.com/image/fetch/$s_!wYnv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03252f00-650d-4ea7-97aa-84f4c0387ea4_1280x580.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>&#128073; So with a single query using <code>ROLLUP</code>, you&#8217;ve got:</p><ul><li><p><strong>year</strong> &#8594; Year of the visit(s).</p></li><li><p><strong>month</strong> &#8594; Month of the visit(s).</p></li><li><p><strong>total_visits</strong> &#8594; How many visits happened in that year/month.</p></li><li><p><strong>row_type</strong> &#8594; Label telling you whether the row is monthly detail, a yearly subtotal, or the overall grand total.</p><h2>How rollups compare to grouping sets:</h2><p>Both <strong>Grouping Sets</strong> and <strong>Rollups</strong> let you collapse multiple aggregations into one query, the difference is in <strong>control vs convenience</strong>.</p><p></p></li><li><p><strong>Grouping Sets</strong> &#8594; You spell out each grouping you want. Perfect when you need a custom mix (e.g. totals by country, by product, but not both together).</p></li><li><p><strong>Rollups</strong> &#8594; You hand SQL a hierarchy, and it builds every subtotal and the grand </p><p>total for you. Less typing, cleaner code, but the shape is fixed.</p></li></ul><h3>In short:</h3><ul><li><p>Use <strong>Grouping Sets</strong> when you want <strong>custom, non-hierarchical views</strong>.</p></li><li><p>Use <strong>Rollups</strong> when you want <strong>hierarchical roll-ups with minimal effort</strong>.</p></li></ul><h2>Analogy</h2><p>&#8220;Rollups are like elevator stops: you can get off at the city floor, the state floor, the country floor, or ride all the way up to the grand total.&#8221;</p><p>It conveys the hierarchical nature (each level builds on the last), but in a way that&#8217;s easy to visualize.</p><div><hr></div><h2>5. Self Joins:</h2><p>A <strong>self join</strong> is simply joining a table to itself. Instead of pulling data from two different tables, you treat the same table as if it were two, usually by giving each instance an alias.</p><h3>Real-world examples:</h3><ul><li><p><strong>Comparing rows</strong>:</p><ul><li><p>In a <strong>weather table</strong>, join each city&#8217;s record to another city&#8217;s record on the same date to compare conditions (e.g., New York&#8217;s temperature vs. Los Angeles&#8217; temperature on June</p></li></ul></li><li><p><strong>Time-series analysis</strong>:</p><ul><li><p>In the same <strong>weather table</strong>, join today&#8217;s weather record for a city to <strong>yesterday&#8217;s record</strong> to track day-over-day changes in temperature, rainfall, or humidity.</p></li></ul><p></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_!LOvv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LOvv!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 424w, https://substackcdn.com/image/fetch/$s_!LOvv!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 848w, https://substackcdn.com/image/fetch/$s_!LOvv!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 1272w, https://substackcdn.com/image/fetch/$s_!LOvv!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LOvv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png" width="618" height="1154.8976377952756" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1424,&quot;width&quot;:762,&quot;resizeWidth&quot;:618,&quot;bytes&quot;:784302,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LOvv!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 424w, https://substackcdn.com/image/fetch/$s_!LOvv!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 848w, https://substackcdn.com/image/fetch/$s_!LOvv!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.png 1272w, https://substackcdn.com/image/fetch/$s_!LOvv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5b751bed-0888-4276-988e-333ebb51a66c_762x1424.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></p><h3>Output:</h3><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!M_5O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!M_5O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 424w, https://substackcdn.com/image/fetch/$s_!M_5O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 848w, https://substackcdn.com/image/fetch/$s_!M_5O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 1272w, https://substackcdn.com/image/fetch/$s_!M_5O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!M_5O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png" width="728" height="97.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:195,&quot;width&quot;:1456,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:92031,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!M_5O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 424w, https://substackcdn.com/image/fetch/$s_!M_5O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 848w, https://substackcdn.com/image/fetch/$s_!M_5O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 1272w, https://substackcdn.com/image/fetch/$s_!M_5O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a793077-8f71-45e4-a0a5-891b7d5835af_2194x294.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>&#9989; <strong>In one query</strong>, you get:</h3><ul><li><p><strong>Row comparison</strong> &#8594; city vs. city, same date.</p></li><li><p><strong>Time-series</strong> &#8594; today vs. yesterday, same city.</p></li><li><p><strong>Changes over time</strong> in temperature, rainfall, humidity.</p></li></ul><h3>Why self joins matter in analytics:</h3><ul><li><p><strong>Comparisons</strong> &#8594; how one row stacks up against another (city vs. city, product vs. similar product).</p></li><li><p><strong>Trends</strong> &#8594; how a row evolves over time (today vs. yesterday&#8217;s weather, last month vs. this month&#8217;s reading).</p></li><li><p><strong>Hierarchies</strong> &#8594; how rows connect in a structure (employee vs. manager, category vs. subcategory).</p></li></ul><p>In analytics, this means you&#8217;re not limited to totals and averages. A self join shows <strong>patterns, progressions, and relationships,</strong> the deeper layer of meaning that makes raw data actionable.</p><h3>Analogy:</h3><p>&#8220;It&#8217;s like comparing today&#8217;s selfie to yesterday&#8217;s, same subject, new context.&#8221;</p><div><hr></div><h2>6. Putting it all together</h2><h3>Scenario: team productivity &#8212; dept &#8594; manager rollups</h3><h3>Problem:</h3><p>In most organizations, productivity metrics are stored at the <strong>employee level</strong> (e.g., hours worked, tasks completed, revenue generated). But business leaders don&#8217;t just need to see this information for individuals, they need <strong>rollups across the hierarchy</strong>:</p><ul><li><p>A <strong>manager</strong> wants to see how their team performed.</p></li><li><p>A <strong>department head</strong> wants to see all their managers&#8217; totals, plus comparisons across them.</p></li><li><p>The <strong>company</strong> wants to see aggregated totals across departments.</p></li></ul><h3>Goal:</h3><ul><li><p>i-level metrics by <strong>department &#215; manager &#215; month</strong></p></li><li><p>Compare employees <strong>under each manager</strong> (self-join to the manager)</p></li><li><p>Get <strong>manager subtotals, department subtotals, company totals</strong>, all in one result</p></li></ul><h3>Assumed tables (map to your schema):</h3><ul><li><p><code>employees(employee_id, full_name, manager_id, department)</code></p></li><li><p><code>work_log(employee_id, work_date)</code> one row per day an employee did work (or any activity event)</p></li></ul><h3>Query:</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!defG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!defG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 424w, https://substackcdn.com/image/fetch/$s_!defG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 848w, https://substackcdn.com/image/fetch/$s_!defG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!defG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!defG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png" width="984" height="1426" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1426,&quot;width&quot;:984,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:788732,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!defG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 424w, https://substackcdn.com/image/fetch/$s_!defG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 848w, https://substackcdn.com/image/fetch/$s_!defG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.png 1272w, https://substackcdn.com/image/fetch/$s_!defG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff94b4e2d-70e0-4bfd-9688-a39d7ed1e650_984x1426.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><h3>Output:</h3><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jMKI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jMKI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 424w, https://substackcdn.com/image/fetch/$s_!jMKI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 848w, https://substackcdn.com/image/fetch/$s_!jMKI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 1272w, https://substackcdn.com/image/fetch/$s_!jMKI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jMKI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png" width="1416" height="1504" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1504,&quot;width&quot;:1416,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:213012,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!jMKI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 424w, https://substackcdn.com/image/fetch/$s_!jMKI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 848w, https://substackcdn.com/image/fetch/$s_!jMKI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.png 1272w, https://substackcdn.com/image/fetch/$s_!jMKI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdc0c04a-cc4e-483a-b955-14907ae3f447_1416x1504.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><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!EM-f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!EM-f!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 424w, https://substackcdn.com/image/fetch/$s_!EM-f!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 848w, https://substackcdn.com/image/fetch/$s_!EM-f!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 1272w, https://substackcdn.com/image/fetch/$s_!EM-f!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!EM-f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png" width="724" height="422.6761363636364" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:822,&quot;width&quot;:1408,&quot;resizeWidth&quot;:724,&quot;bytes&quot;:109851,&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;:&quot;https://www.dataman.blog/i/174601122?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!EM-f!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 424w, https://substackcdn.com/image/fetch/$s_!EM-f!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 848w, https://substackcdn.com/image/fetch/$s_!EM-f!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.png 1272w, https://substackcdn.com/image/fetch/$s_!EM-f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F46be46c0-0319-4276-b0cb-4c5c97c599e7_1408x822.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></p><p></p><div><hr></div><h2>7. &#8220;Challenges &amp; pro tips&#8221;</h2><h3><strong>1. Performance pitfalls:</strong></h3><p>Queries with self-joins, grouping sets, and rollups can scan huge volumes of data, making them slow and resource-intensive on large datasets.</p><h3>2. Aggregate placeholders in rollups and grouping sets:</h3><p>When you use <strong>ROLLUP</strong> or <strong>GROUPING SETS</strong>, SQL adds extra rows for <strong>subtotals and grand totals</strong>. In those rows, the grouped columns are filled with <code>NULL</code> , not because the data is missing, but as a <strong>marker</strong> that this row represents an aggregate.</p><h3>3. Where self-joins fall short:</h3><ul><li><p><strong>Performance overhead</strong> &#8594; Joining a large table to itself often doubles the data scanned and can make queries very slow.</p></li><li><p><strong>Complexity</strong> &#8594; Queries become harder to read and maintain, especially with multiple conditions across the same table.</p></li><li><p><strong>Scalability issues</strong> &#8594; On very large datasets, self-joins may time out or require excessive compute compared to equivalent window function solutions.</p></li></ul><h3>Pro tips :</h3><p><strong>1. Speed up queries</strong></p><ul><li><p>Summarize data first (like user&#8211;month).</p></li><li><p>Add indexes on important columns.</p></li><li><p>Only check key retention periods (Month+1, Month+2).</p></li></ul><p><strong>2. Read totals clearly</strong></p><ul><li><p>Use <code>GROUPING()</code> to know which rows are subtotals.</p></li><li><p>Change <code>NULL</code>s into labels like ALL MONTHS or ALL YEARS.</p></li></ul><p><strong>3. Use window functions</strong></p><ul><li><p>Try <code>LAG</code>, <code>LEAD</code>, or <code>ROW_NUMBER</code> instead of self-joins.</p></li><li><p>They are faster, cleaner, and scale better.</p></li></ul><h2>8. The big picture: why It&#8217;s useful</h2><p>At the end of the blog, <code>ROLLUP</code> and <code>GROUPING SETS</code> aren&#8217;t obscure SQL tricks, they&#8217;re shortcuts to thinking and working like an analyst. They turn three or four repetitive queries into one clear, maintainable query that scales with your questions. Fewer queries mean fewer errors, faster answers, and cleaner code.</p><p><strong>So here&#8217;s the takeaway:</strong></p><p>Next time you catch yourself writing multiple <code>GROUP BY</code> queries in a row, stop and ask, could this be one query with <code>ROLLUP</code> or <code>GROUPING SETS</code>?</p><div><hr></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.dataman.blog/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading dat-a-man &#8212; Data with Aman! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[SQL Window functions deep dive]]></title><description><![CDATA[What window functions can do and what they cannot.]]></description><link>https://www.dataman.blog/p/sql-window-functions-deep-dive</link><guid isPermaLink="false">https://www.dataman.blog/p/sql-window-functions-deep-dive</guid><dc:creator><![CDATA[Aman Gupta]]></dc:creator><pubDate>Fri, 29 Aug 2025 05:08:29 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!1ow4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1ow4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1ow4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 424w, https://substackcdn.com/image/fetch/$s_!1ow4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 848w, https://substackcdn.com/image/fetch/$s_!1ow4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!1ow4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1ow4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png" width="327" height="490.5" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1536,&quot;width&quot;:1024,&quot;resizeWidth&quot;:327,&quot;bytes&quot;:2642668,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1ow4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 424w, https://substackcdn.com/image/fetch/$s_!1ow4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 848w, https://substackcdn.com/image/fetch/$s_!1ow4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!1ow4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da890b6-9c47-45b0-b357-921cb624f110_1024x1536.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><p></p><h2><strong>Introduction:</strong></h2><p>In Today&#8217;s analytics, raw data alone isn&#8217;t enough, what matters is how flexibly and deeply you can explore it. When analyzing data, it&#8217;s often important to calculate values like running totals, rankings, or comparisons between rows, without losing the details of each row. That&#8217;s where SQL window functions come in.</p><p>They let you perform powerful calculations across related rows while keeping every row in your results. This makes it easier to spot trends, compare values, and build more insightful reports. Whether you're just starting with SQL or looking to improve your analysis skills, understanding window functions is a valuable step forward.</p><h3>SQL Window Functions Core Concepts:</h3><p>Each window function uses the OVER clause to define its scope. You can refine this window with:</p><ul><li><p><strong>PARTITION BY</strong> to divide data into groups for independent calculations,</p></li><li><p><strong>ORDER BY</strong> to set row order within each group for operations like rankings or running totals.</p></li></ul><h4>Window functions fall into several key categories:</h4><ul><li><p><strong>Aggregate functions</strong> (SUM(), AVG(), COUNT()) for running totals or moving averages.</p></li><li><p><strong>Ranking functions</strong> (ROW_NUMBER(), RANK(), DENSE_RANK()) to assign positions or ranks within partitions.</p></li><li><p><strong>Value functions</strong> (LAG(), LEAD(), FIRST_VALUE(), LAST_VALUE()) to access values from other rows in the window.</p><p></p><p><strong>Example:</strong></p></li></ul><p> This example calculates a cumulative total of duration_seconds ordered by   start_time, without grouping or removing rows.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Txa0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Txa0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 424w, https://substackcdn.com/image/fetch/$s_!Txa0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 848w, https://substackcdn.com/image/fetch/$s_!Txa0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 1272w, https://substackcdn.com/image/fetch/$s_!Txa0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Txa0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png" width="1456" height="335" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:335,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1262716,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Txa0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 424w, https://substackcdn.com/image/fetch/$s_!Txa0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 848w, https://substackcdn.com/image/fetch/$s_!Txa0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 1272w, https://substackcdn.com/image/fetch/$s_!Txa0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e3238e5-9c36-4454-ba77-fe26215ae6f0_2884x664.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>This example calculates a cumulative total of duration_seconds ordered by start_time, without grouping or removing rows.</p><div><hr></div><h2>Primary SQL Ranking Functions:</h2><p>Ranking functions in SQL are specialized window functions that assign ranks to rows based on their ordering within a dataset. The primary ranking functions are ROW_NUMBER(), RANK(), DENSE_RANK(), and NTILE().</p><ul><li><p><strong>ROW_NUMBER() </strong>- <code>ROW_NUMBER()</code> is a <strong>window function in SQL</strong> that assigns a unique sequential integer to rows within a result set, based on the order you specify.</p><p></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!22H5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!22H5!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 424w, https://substackcdn.com/image/fetch/$s_!22H5!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 848w, https://substackcdn.com/image/fetch/$s_!22H5!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 1272w, https://substackcdn.com/image/fetch/$s_!22H5!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!22H5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png" width="581" height="219.0721153846154" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:549,&quot;width&quot;:1456,&quot;resizeWidth&quot;:581,&quot;bytes&quot;:1206724,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!22H5!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 424w, https://substackcdn.com/image/fetch/$s_!22H5!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 848w, https://substackcdn.com/image/fetch/$s_!22H5!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 1272w, https://substackcdn.com/image/fetch/$s_!22H5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffb90402d-e167-40f5-a6d0-2a2faa03b7de_2228x840.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p><strong>   Output:</strong></p><p>  The query would produce:</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_!LfnT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LfnT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!LfnT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!LfnT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!LfnT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LfnT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png" width="255" height="255" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:255,&quot;bytes&quot;:1286176,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!LfnT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!LfnT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!LfnT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!LfnT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fec7acf55-d2f1-4e37-9cd4-bb6a7b23481d_1024x1024.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><ul><li><p><strong>RANK()</strong>: Assigns ranks to rows, but if rows have identical values per the ORDER BY clause, they receive the same rank. This may create gaps in the rankings after ties (i.e., if two rows are ranked 1, the next row is ranked 3).</p><p></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!z-79!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!z-79!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 424w, https://substackcdn.com/image/fetch/$s_!z-79!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 848w, https://substackcdn.com/image/fetch/$s_!z-79!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 1272w, https://substackcdn.com/image/fetch/$s_!z-79!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!z-79!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png" width="573" height="231.40384615384616" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:588,&quot;width&quot;:1456,&quot;resizeWidth&quot;:573,&quot;bytes&quot;:1141903,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!z-79!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 424w, https://substackcdn.com/image/fetch/$s_!z-79!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 848w, https://substackcdn.com/image/fetch/$s_!z-79!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 1272w, https://substackcdn.com/image/fetch/$s_!z-79!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a1cdcc6-f78f-4a67-b23c-3fdc4758413b_2080x840.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p><strong>Output:</strong></p><p>The query would produce:</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_!e3uf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!e3uf!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!e3uf!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!e3uf!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!e3uf!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!e3uf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png" width="249" height="249" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:249,&quot;bytes&quot;:1323172,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!e3uf!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!e3uf!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!e3uf!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!e3uf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F129f117e-15d1-4ce6-a9b9-86193addb605_1024x1024.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><ul><li><p><strong>DENSE_RANK()</strong>: Functions similarly to RANK(), but does not leave gaps in the ranking sequence after ties. If two rows are tied for rank 1, the next row is assigned rank 2.</p><p></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j0zq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j0zq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 424w, https://substackcdn.com/image/fetch/$s_!j0zq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 848w, https://substackcdn.com/image/fetch/$s_!j0zq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 1272w, https://substackcdn.com/image/fetch/$s_!j0zq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!j0zq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png" width="589" height="211.57074175824175" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:523,&quot;width&quot;:1456,&quot;resizeWidth&quot;:589,&quot;bytes&quot;:1268246,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!j0zq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 424w, https://substackcdn.com/image/fetch/$s_!j0zq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 848w, https://substackcdn.com/image/fetch/$s_!j0zq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 1272w, https://substackcdn.com/image/fetch/$s_!j0zq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa2709e5-750c-4da3-9205-87bd83f43f9b_2340x840.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p><strong>Output:</strong></p><p>The query would produce:</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_!pu78!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pu78!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!pu78!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!pu78!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!pu78!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pu78!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png" width="265" height="265" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:265,&quot;bytes&quot;:1350684,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!pu78!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!pu78!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!pu78!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!pu78!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F740ff71e-deea-4f87-98a0-199346c41311_1024x1024.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><ul><li><p><strong>NTILE(n)</strong>: Divides the data into n equal or nearly equal groups and assigns each row a group number.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yqiL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yqiL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 424w, https://substackcdn.com/image/fetch/$s_!yqiL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 848w, https://substackcdn.com/image/fetch/$s_!yqiL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 1272w, https://substackcdn.com/image/fetch/$s_!yqiL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yqiL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png" width="567" height="224.6971153846154" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:577,&quot;width&quot;:1456,&quot;resizeWidth&quot;:567,&quot;bytes&quot;:1154825,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!yqiL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 424w, https://substackcdn.com/image/fetch/$s_!yqiL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 848w, https://substackcdn.com/image/fetch/$s_!yqiL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 1272w, https://substackcdn.com/image/fetch/$s_!yqiL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a2ec133-bb77-4939-825b-cda48c6a4945_2120x840.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p><strong>Output</strong> :</p><p>(rows split into 4 nearly equal buckets, highest values in quartile 1)</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_!UFdP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UFdP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!UFdP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!UFdP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!UFdP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UFdP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png" width="298" height="298" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:298,&quot;bytes&quot;:728727,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UFdP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!UFdP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!UFdP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!UFdP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F025bd615-587c-4c38-a9ad-da2888998ff2_1024x1024.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><div><hr></div><h2>&#128230; Key Navigation Functions</h2><p><strong>Navigation functions</strong> are a subset of SQL <strong>window functions</strong> that allow you to <strong>access values from rows adjacent to the current row</strong> within a defined window. These adjacent rows can be from <strong>before (LAG)</strong> or <strong>after (LEAD)</strong> the current row. Other navigation functions include FIRST_VALUE() and LAST_VALUE() which retrieve boundary values within each window.</p><p>The navigation summary for the LEAD() , LAG(), FIRST_VALUE() and LAST_VALUE() functions from the SQL time-series window functions is as follows:</p><h3><strong>LEAD and LAG</strong></h3><ul><li><p><strong>Purpose</strong>: The LEAD and LAG functions enable access to data from rows after (LEAD) or before (LAG) the current row within a result set ordered by a specific column, making them ideal for time-series and sequential data analysis.</p></li><li><p><strong>Functionality</strong>: LEAD looks "into the future" (next rows), while LAG looks "into the past" (previous rows). They are frequently used to calculate differences between consecutive data points, such as monthly stock prices or moving averages.</p></li></ul><h3><strong>FIRST_VALUE() and LAST_VALUE()</strong></h3><ul><li><p><strong>Purpose</strong>:</p><p><code>FIRST_VALUE()</code> and <code>LAST_VALUE()</code> return the <strong>first</strong> and <strong>last value</strong> within the ordered window of each partition. They're ideal when you need to <strong>reference the starting or ending state</strong> of a sequence, like the first purchase amount, the initial score, or the last known status.</p></li><li><p><strong>Functionality</strong>:</p><ul><li><p><code>FIRST_VALUE()</code> captures the <strong>earliest value</strong> in the ordered set.</p></li><li><p><code>LAST_VALUE()</code> captures the <strong>latest value</strong>, but note: its behavior depends on the <strong>window frame definition</strong>. Without correct frame specification, it may return the current row&#8217;s value instead of the true &#8220;last&#8221; row.</p></li></ul></li></ul><h4>Example:</h4><h3>Imagine a Scenario : Analyzing Employee Promotion Patterns in an organisation</h3><h4>Business Use Case:</h4><p>An HR analytics team wants to understand <strong>employee promotion trends</strong> over time. Specifically, they want to know:</p><ul><li><p>When each employee got promoted.</p></li><li><p>What was their <strong>previous job title</strong> (<code>LAG()</code>).</p></li><li><p>What is their <strong>next job title</strong> (<code>LEAD()</code>).</p></li><li><p>What was their <strong>first-ever title</strong> in the company (<code>FIRST_VALUE()</code>).</p></li><li><p>What is their <strong>current/latest title</strong> (<code>LAST_VALUE()</code>).</p></li></ul><h4>SQL query:</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!da2V!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!da2V!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 424w, https://substackcdn.com/image/fetch/$s_!da2V!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 848w, https://substackcdn.com/image/fetch/$s_!da2V!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 1272w, https://substackcdn.com/image/fetch/$s_!da2V!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!da2V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png" width="1456" height="1708" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1708,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:4475987,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!da2V!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 424w, https://substackcdn.com/image/fetch/$s_!da2V!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 848w, https://substackcdn.com/image/fetch/$s_!da2V!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.png 1272w, https://substackcdn.com/image/fetch/$s_!da2V!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9c49a1c-942a-4a51-b885-4b1fa9b8d1dc_2592x3040.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><strong>&#9989; Output of query on that data</strong></p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!TaxF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!TaxF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!TaxF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!TaxF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!TaxF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!TaxF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png" width="445" height="445" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:445,&quot;bytes&quot;:1404227,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!TaxF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!TaxF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!TaxF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!TaxF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffba5bccc-e27e-4a06-831f-e3f4d0292baf_1024x1024.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><div><hr></div><h2>What is an Aggregate Function?</h2><p>An <strong>aggregate function</strong> in SQL is a special type of function that takes <strong>multiple rows of data</strong> and <strong>condenses them into a single value</strong> based on a calculation you specify.</p><p>They&#8217;re used when you want <strong>summarized information</strong>, such as totals, averages, or counts, rather than listing individual rows.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Hy2K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Hy2K!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Hy2K!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Hy2K!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Hy2K!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Hy2K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2277936,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Hy2K!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Hy2K!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Hy2K!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Hy2K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F410d41cf-caf4-438a-8394-f6c269167be7_1536x1024.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><h3><strong>Common SQL aggregate functions include:</strong></h3><p>&#8226; <strong>COUNT()</strong>: Returns the number of rows in a set, or the number of non-NULL values in a specified column.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rmLj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rmLj!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 424w, https://substackcdn.com/image/fetch/$s_!rmLj!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 848w, https://substackcdn.com/image/fetch/$s_!rmLj!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 1272w, https://substackcdn.com/image/fetch/$s_!rmLj!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rmLj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png" width="584" height="148.4065934065934" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:370,&quot;width&quot;:1456,&quot;resizeWidth&quot;:584,&quot;bytes&quot;:767955,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rmLj!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 424w, https://substackcdn.com/image/fetch/$s_!rmLj!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 848w, https://substackcdn.com/image/fetch/$s_!rmLj!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 1272w, https://substackcdn.com/image/fetch/$s_!rmLj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff531fefa-e35a-4d4a-a5fb-cb66827c592f_2080x528.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>&#8226; <strong>SUM()</strong>: Calculates the total sum of values in a numeric column.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!m-8D!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!m-8D!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 424w, https://substackcdn.com/image/fetch/$s_!m-8D!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 848w, https://substackcdn.com/image/fetch/$s_!m-8D!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 1272w, https://substackcdn.com/image/fetch/$s_!m-8D!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!m-8D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png" width="569" height="157.49107142857142" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:403,&quot;width&quot;:1456,&quot;resizeWidth&quot;:569,&quot;bytes&quot;:825044,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!m-8D!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 424w, https://substackcdn.com/image/fetch/$s_!m-8D!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 848w, https://substackcdn.com/image/fetch/$s_!m-8D!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 1272w, https://substackcdn.com/image/fetch/$s_!m-8D!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b76b895-5bf4-45ab-abe6-7ff13be9b04f_2080x576.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>&#8226; <strong>MIN()</strong>: Retrieves the minimum value from a specified column.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1uKc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1uKc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 424w, https://substackcdn.com/image/fetch/$s_!1uKc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 848w, https://substackcdn.com/image/fetch/$s_!1uKc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 1272w, https://substackcdn.com/image/fetch/$s_!1uKc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1uKc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png" width="597" height="165.24107142857142" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:403,&quot;width&quot;:1456,&quot;resizeWidth&quot;:597,&quot;bytes&quot;:824427,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!1uKc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 424w, https://substackcdn.com/image/fetch/$s_!1uKc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 848w, https://substackcdn.com/image/fetch/$s_!1uKc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 1272w, https://substackcdn.com/image/fetch/$s_!1uKc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bdb70ef-baee-4c22-9138-c54ff3b37aec_2080x576.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>&#8226; <strong>MAX()</strong>: Retrieves the maximum value from a specified column.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!OdBg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!OdBg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 424w, https://substackcdn.com/image/fetch/$s_!OdBg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 848w, https://substackcdn.com/image/fetch/$s_!OdBg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 1272w, https://substackcdn.com/image/fetch/$s_!OdBg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!OdBg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png" width="593" height="164.13392857142858" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:403,&quot;width&quot;:1456,&quot;resizeWidth&quot;:593,&quot;bytes&quot;:825899,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!OdBg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 424w, https://substackcdn.com/image/fetch/$s_!OdBg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 848w, https://substackcdn.com/image/fetch/$s_!OdBg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 1272w, https://substackcdn.com/image/fetch/$s_!OdBg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3da563ca-e2d7-4794-98a1-b81a33f7c2c3_2080x576.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3><strong>&#128202; Business Use Cases for Aggregation</strong></h3><h4>&#128717; <strong>Retail &amp; E-Commerce:</strong></h4><ul><li><p><strong>Sales Reporting:</strong> Calculate <code>SUM(sales_amount)</code> to find total revenue per day, month, or store.</p></li><li><p><strong>Top-Selling Products:</strong> Use <code>COUNT(product_id)</code> grouped by product to identify best performers.</p></li></ul><h4>&#127973; <strong>Healthcare</strong></h4><ul><li><p><strong>Patient Volume:</strong> Use <code>COUNT(patient_id)</code> to track inflow by department.</p></li><li><p><strong>Treatment Success Rate:</strong> Aggregate outcomes with <code>SUM(successful_cases)</code> / <code>SUM(total_cases)</code>.</p></li></ul><h4>&#127891; <strong>Education</strong></h4><ul><li><p><strong>Performance Tracking:</strong> <code>AVG(marks)</code> per subject or class.</p></li><li><p><strong>Top Scores:</strong> Identify <code>MAX(score)</code> for award consideration.</p></li></ul><div><hr></div><h2>Advanced patterns of SQL Window Functions:</h2><h3>1. Row-to-Row Comparisons</h3><ul><li><p><strong>Functions Used:</strong> <code>LAG()</code> and <code>LEAD()</code></p></li><li><p><strong>Purpose:</strong> Compare a row with its preceding or following row within the same partition.</p></li><li><p><strong>Typical Applications:</strong></p><ul><li><p>Finding trends or changes over time</p></li><li><p>Calculating deltas between consecutive events</p></li><li><p>Detecting anomalies in sequential data</p></li></ul></li></ul><p><strong>         (Conceptual Example):</strong></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!IA9E!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!IA9E!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 424w, https://substackcdn.com/image/fetch/$s_!IA9E!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 848w, https://substackcdn.com/image/fetch/$s_!IA9E!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 1272w, https://substackcdn.com/image/fetch/$s_!IA9E!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!IA9E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png" width="603" height="209.97321428571428" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:507,&quot;width&quot;:1456,&quot;resizeWidth&quot;:603,&quot;bytes&quot;:1945136,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!IA9E!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 424w, https://substackcdn.com/image/fetch/$s_!IA9E!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 848w, https://substackcdn.com/image/fetch/$s_!IA9E!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 1272w, https://substackcdn.com/image/fetch/$s_!IA9E!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F613ae5d0-3269-4e2d-8c35-3b5282262278_2920x1016.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>2. Rolling and Moving Calculations</h3><ul><li><p><strong>Functions Used:</strong> <code>AVG()</code>, <code>SUM()</code>, etc., combined with window frames</p></li><li><p><strong>Purpose:</strong> Compute metrics like rolling sums, running averages, or cumulative totals.</p></li><li><p><strong>Applications:</strong></p><ul><li><p>Smoothing time-series</p></li><li><p>Spotting moving trends</p></li><li><p>Monitoring performance metrics</p></li></ul></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_!iepn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iepn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 424w, https://substackcdn.com/image/fetch/$s_!iepn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 848w, https://substackcdn.com/image/fetch/$s_!iepn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 1272w, https://substackcdn.com/image/fetch/$s_!iepn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iepn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png" width="521" height="276.60233516483515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:773,&quot;width&quot;:1456,&quot;resizeWidth&quot;:521,&quot;bytes&quot;:1529259,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!iepn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 424w, https://substackcdn.com/image/fetch/$s_!iepn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 848w, https://substackcdn.com/image/fetch/$s_!iepn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.png 1272w, https://substackcdn.com/image/fetch/$s_!iepn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7cbe4eac-eff6-4f97-a2d7-1b84355a0ec4_2080x1104.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><h3>4. Conditional Insights</h3><ul><li><p><strong>Approach:</strong> Use <code>CASE</code> inside a window function to apply conditional aggregations.</p></li><li><p><strong>Applications:</strong></p><ul><li><p>Aggregating only certain categories of data while still operating in a partition</p></li><li><p>Segmenting by logic without breaking partitions</p></li></ul><p></p><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rLjI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rLjI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 424w, https://substackcdn.com/image/fetch/$s_!rLjI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 848w, https://substackcdn.com/image/fetch/$s_!rLjI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 1272w, https://substackcdn.com/image/fetch/$s_!rLjI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rLjI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png" width="591" height="220.8131868131868" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:544,&quot;width&quot;:1456,&quot;resizeWidth&quot;:591,&quot;bytes&quot;:1530905,&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;:&quot;https://adatayogi.substack.com/i/172060073?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rLjI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 424w, https://substackcdn.com/image/fetch/$s_!rLjI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 848w, https://substackcdn.com/image/fetch/$s_!rLjI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 1272w, https://substackcdn.com/image/fetch/$s_!rLjI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F96829833-8ccb-4c04-84d7-640bd963b260_2484x928.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p></p><h3>Performance Principles:</h3><ul><li><p><strong>Indexes &amp; Partitions</strong></p><ul><li><p>Index columns that are used in <code>PARTITION BY</code> and <code>ORDER BY</code>.</p></li><li><p>Consider table partitioning to reduce the data each query scans.</p></li></ul></li><li><p><strong>Window Frame Efficiency</strong></p><ul><li><p>Use <strong>specific frames</strong> (e.g., <code>ROWS BETWEEN 3 PRECEDING AND CURRENT ROW</code>) instead of broad ones like <code>UNBOUNDED PRECEDING</code> when possible. Narrow windows run faster.</p></li></ul></li><li><p><strong>Reduce Complexity</strong></p><ul><li><p>Keep only necessary columns in the <code>OVER()</code> clause.</p></li><li><p>Simplify expressions inside window functions; push heavy calculations outside the window if possible.</p></li></ul></li><li><p><strong>Benchmark Queries</strong></p><ul><li><p>Run queries on real or representative datasets.</p></li><li><p>Use <strong>EXPLAIN / execution plans</strong> or profiling tools to spot slow steps.</p><p></p></li></ul><p></p></li></ul><div><hr></div><h2>Quick best practices</h2><ul><li><p><strong>Use only when needed.</strong> If a <code>GROUP BY</code> works, use that.</p></li><li><p><strong>Set </strong><code>PARTITION BY</code><strong> and </strong><code>ORDER BY</code><strong> carefully,</strong> add a tiebreaker (e.g., <code>ORDER BY ts, id</code>).</p></li><li><p><strong>Filter early, select fewer columns</strong> before the window step.</p></li><li><p><strong>Use tight frames</strong> (<code>ROWS BETWEEN N PRECEDING AND CURRENT ROW</code>) instead of unbounded history.</p></li><li><p><strong>Reuse results,</strong> don&#8217;t compute the same window twice (or use <code>QUALIFY</code> where available).</p></li><li><p><strong>Handle NULLs</strong> in <code>LAG/LEAD</code> with a default value.</p></li><li><p><strong>Watch performance:</strong> check the plan/profile; index/partition on the columns you partition/order by.</p></li></ul><h3>Conclusion</h3><p>Window functions add trends, ranks, and rolling metrics without losing row detail. Keep them predictable and fast with precise ordering, small frames, and smaller inputs, and always verify with the execution plan.</p></li></ul><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.dataman.blog/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading A Data Yogi! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Why LY Corporation made the big switch to Apache Iceberg]]></title><description><![CDATA[(DEN)]]></description><link>https://www.dataman.blog/p/why-ly-corporation-made-the-big-switch</link><guid isPermaLink="false">https://www.dataman.blog/p/why-ly-corporation-made-the-big-switch</guid><dc:creator><![CDATA[Aman Gupta]]></dc:creator><pubDate>Tue, 08 Jul 2025 10:34:41 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!abBl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Switching to Apache Iceberg for Better Data Management (Explained Like I&#8217;m Talking to My 5-Year-Old Daughter)</p><p>Imagine you're a 5-year-old with a massive toy collection that keeps growing every day. You have toys everywhere, and it takes you <strong>over an hour</strong> just to find the specific toy you want to play with. That's exactly what was happening to LY Corporation, one of Japan's biggest tech companies!</p><h2>What is LY Corporation?</h2><p>LY Corporation is like a giant digital playground. Think of it as the company that runs:</p><ul><li><p><strong>LINE</strong> - the messaging app that almost everyone in Japan uses (like WhatsApp but way more popular)</p></li><li><p><strong>Yahoo! JAPAN</strong> - the website where people search for things and read news</p></li><li><p><strong>PayPay</strong> - the app people use to pay for things with their phones</p></li></ul><p>They have over <strong>320 million users</strong> across Asia and handle more data than you can imagine - we're talking about <strong>1.1 exabytes</strong>, which is like having 1.1 billion huge toy boxes full of information!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!abBl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!abBl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!abBl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!abBl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!abBl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!abBl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2957300,&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;:&quot;https://www.den.digital/i/167789205?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!abBl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!abBl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!abBl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!abBl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff9ff2667-d7b6-42d2-bebb-2d735e2a88da_1536x1024.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><h2>How big is their data?</h2><p>To understand how massive LY Corporation's data is, let's use simple numbers:</p><ul><li><p>They have <strong>over 100,000 tables</strong> (think of each table as a different type of toy box)</p></li><li><p>Every single day, they process <strong>1.2 trillion records</strong> (that's like counting to 1.2 followed by 12 zeros!)</p></li><li><p>Their data is growing <strong>really, really fast</strong> because millions of people use their apps every day</p></li></ul><h2>What was their old data system like?</h2><p>Before Apache Iceberg, LY Corporation was using something called <strong>Hive</strong> (think of it as their old toy organization system). Here's how it worked:</p><h2>The old way (Hive System)</h2><ul><li><p><strong>Data collection</strong>: People using LINE, Yahoo, and PayPay would create data (like sending messages, searching, making payments)</p></li><li><p><strong>Data journey</strong>: This data would travel through something called <strong>Kafka</strong> (like a conveyor belt) to <strong>Flink</strong> (a processing machine) and finally land in <strong>HDFS</strong> storage (the toy warehouse)</p></li><li><p><strong>Format conversion</strong>: The data would start as <strong>AVRO and Protocol Buffer files</strong> and then get converted to <strong>ORC format</strong> every hour</p></li><li><p><strong>The big wait</strong>: It took <strong>1 to 1.5 hours</strong> before anyone could actually use this data</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_!Dd7B!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Dd7B!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Dd7B!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Dd7B!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Dd7B!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Dd7B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3471607,&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;:&quot;https://www.den.digital/i/167789205?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Dd7B!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Dd7B!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Dd7B!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Dd7B!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe9073190-6d47-49f0-bfc0-b8dc5312a031_1536x1024.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><h2>The problems they faced</h2><p>Remember when your room was so messy you couldn't find your favorite toy car under a pile of socks and Legos? LY Corporation had the same problem, just with, you know, <em>terabytes</em> of data.</p><h3>1. Super slow data access</h3><p>Getting fresh data took them over an hour. Yep, an <em>hour</em>.</p><p>In a world where modern businesses need data in <em>minutes</em>, not &#8220;go-make-a-coffee-and-come-back&#8221; hours, this was a big problem. Their machine learning models and real-time services were basically stuck waiting around, tapping their feet.</p><h3>2. The tiny files chaos</h3><p>Imagine having a million tiny toy boxes instead of a few big, organized ones. LY Corp&#8217;s system (HDFS) was drowning in these tiny files, each demanding attention.</p><p>And the &#8220;brain&#8221; of their system (the namenode) was getting so overloaded trying to keep track that it was running out of memory, like your laptop when you have 47 Chrome tabs open.</p><h3>3. Deleting data was a nightmare</h3><p>When someone requested their personal data be deleted (think GDPR and privacy laws), it wasn&#8217;t just a quick &#8220;delete&#8221; button. Nope.</p><p>They had to rewrite <em>huge</em> files just to remove a single person&#8217;s data. Imagine having to rewrite your entire diary just to erase one sentence. Painful.</p><h3>4. Schema changes were a disaster</h3><p>Adding or removing data fields? It was like having to reorganize your entire Lego collection every time you bought a new set.</p><h2>Why did they choose Apache Iceberg?</h2><p>Apache Iceberg is like a <strong>super-smart toy organization system</strong>. Here's why LY Corporation fell in love with it:</p><p><strong>1. Delete specific things easily</strong></p><ul><li><p>Instead of emptying entire toy boxes to remove one toy, Iceberg can point to exactly what needs to be deleted</p></li><li><p>Perfect for when people ask to have their personal data removed (GDPR compliance)</p></li></ul><p><strong>2. Make data available super fast</strong></p><ul><li><p>Reduced their data delay from <strong>1.5 hours to just 5 minutes</strong></p></li><li><p>That's <strong>10-12 times faster</strong>!</p></li></ul><p><strong>3. Easy changes without big mess</strong></p><ul><li><p>Adding new data fields is like adding new compartments to your toy box without emptying everything out</p></li><li><p><strong>Schema evolution</strong> made it simple to adapt as their services grew</p></li></ul><p><strong>4. Better organization</strong></p><ul><li><p>Iceberg manages <strong>metadata</strong> (information about information) much more efficiently</p></li><li><p>Reduces pressure on their central database (Hive Metastore)</p></li></ul><p>Think of Apache Iceberg as having a <strong>magical catalog (</strong>Iceberg&#8217;s manifest and metadata approach) that knows exactly where every piece of data is stored and can retrieve it when needed.</p><h2>How Did they actually make the switch?</h2><h4>The migration strategy</h4><p>LY Corporation was smart - they didn't try to change everything at once! Here's what they did:</p><p><strong>Gradual migration approach</strong></p><ul><li><p>Started with <strong>new tables</strong> that needed Iceberg's special features</p></li><li><p>Migrated <strong>8,000+ tables</strong> to Iceberg by 2024</p></li><li><p>Still have <strong>90,000+ tables</strong> on the old Hive system</p></li><li><p>Only migrate tables that actually benefit from Iceberg's features</p></li></ul><h3>The new technical setup</h3><p><strong>New Data pipeline</strong>:</p><ul><li><p><strong>Kafka</strong> (data conveyor belt) &#8594; <strong>Flink</strong> (processing) &#8594; <strong>Apache Iceberg</strong> (smart storage)</p></li><li><p>Data gets flushed every <strong>5 minutes</strong> instead of every hour</p></li><li><p>Files are stored in <strong>ORC format</strong> (efficient storage format)</p></li><li><p>Everything runs on <strong>Kubernetes</strong> (modern container platform)</p></li></ul><h2>What the table optimizer does</h2><p>Think of LY&#8217;s Table optimizer as an automated janitor for Iceberg tables, keeping them fast, tidy, and cost-efficient without manual babysitting.</p><h4>Coordinator</h4><p>Acts like a manager, watching all tables to see which need maintenance. It keeps a smart queue, prioritizing based on file size, file count, or table health.</p><h4>Workers</h4><p>Workers are the system&#8217;s hands, they execute tasks from the coordinator, like merging files and cleaning data, all in parallel for speed and efficiency.</p><h4>Automatic compaction</h4><p>Automatic compaction merges many small files into larger ones, using smart strategies like bin-packing or sorting, to speed up queries and reduce storage waste.</p><h4>Snapshot management</h4><p>Iceberg&#8217;s time travel creates snapshots with every change. The optimizer prunes old snapshots and cleans up orphan files to save space and keep metadata lean.</p><h4>Spark jobs</h4><p>File rewrites and data merges are handled by distributed Spark jobs, scheduled and assigned by the coordinator for efficient processing at scale.</p><h2>How It&#8217;s built</h2><ul><li><p><strong>Microservices on Kubernetes</strong>: Fully distributed, scalable, and resilient, with coordinators and workers scaled independently.</p></li><li><p><strong>Automated scheduling</strong>: Maintenance runs on autopilot, prioritizing urgent tasks and balancing workload.</p></li><li><p><strong>Monitoring &amp; health checks</strong>: Continuously tracks table health, file counts, and performance, alerting or auto-fixing as needed.</p></li><li><p><strong>Conflict prevention</strong>: Prevents overlapping maintenance and user operations on the same table, ensuring safe, conflict-free optimizations.</p></li></ul><p><strong>In short:</strong><br>The Table Optimizer keeps LY&#8217;s Iceberg tables clean and fast, automatically handling compaction, cleanup, and snapshot pruning, so the team can focus on building, not babysitting tables.</p><h2>What challenges did they face?</h2><p>Even with a great plan, moving this much data wasn't easy:</p><h3>Migration challenges</h3><p><strong>1. Deciding what to migrate</strong></p><ul><li><p>With 100,000+ tables, they had to carefully choose which ones would benefit from Iceberg</p></li><li><p>Tables that were small or didn't need Iceberg's features could stay on Hive</p></li></ul><p><strong>2. User training</strong></p><ul><li><p>Data engineers and analysts needed to learn new tools and concepts</p></li><li><p>Not everyone understood Iceberg's advanced features initially</p></li></ul><p><strong>3. Data copying between systems</strong></p><ul><li><p>Their old backup strategy (DistCP) needed to be redesigned for Iceberg</p></li><li><p>Moving data between different storage systems became more complex</p><p></p></li></ul><h2>Ongoing challenges</h2><p>Even with their big clean-up, LY Corp still has a few chores to keep things running smoothly.</p><h4>1. Table housekeeping</h4><p>Iceberg tables don&#8217;t magically stay fast and efficient. They need regular &#8220;housekeeping&#8221; to keep them tidy and optimized, kind of like sweeping the floor before the dust bunnies take over.</p><p>Sure, their Table Optimizer helps a lot, but it&#8217;s still an ongoing chore they can&#8217;t ignore.</p><h4>2. File size juggling</h4><p>Too many tiny files? Bad for performance. Super large files? Harder to manage.</p><p>It&#8217;s a balancing act, like pouring cereal without spilling. Automatic compaction steps in to help, merging those tiny files into more manageable sizes to keep everything humming along.</p><h2>What goals did they achieve?</h2><p>LY Corporation hit some amazing targets:</p><h3>Performance improvements</h3><p><strong>1. Massive speed boost</strong></p><ul><li><p><strong>Data latency</strong>: From 1.5 hours to 5 minutes (10-12x faster)</p></li><li><p><strong>Query performance</strong>: Much faster due to better file organization</p></li><li><p><strong>Real-time capabilities</strong>: Better support for online machine learning</p></li></ul><p><strong>2. Operational efficiency</strong></p><ul><li><p><strong>Automated maintenance</strong>: Less manual work for data engineers</p></li><li><p><strong>Better resource utilization</strong>: More efficient use of computing power</p></li><li><p><strong>Reduced complexity</strong>: Simpler data pipeline management</p></li></ul><h3>Business benefits</h3><p><strong>1. Compliance made easy</strong></p><ul><li><p><strong>GDPR compliance</strong>: Can efficiently delete user data when requested</p></li><li><p><strong>Data governance</strong>: Better control over data lifecycle</p></li><li><p><strong>Audit capabilities</strong>: Clear tracking of data changes</p></li></ul><p><strong>2. Business agility</strong></p><ul><li><p><strong>Faster insights</strong>: Data available for analysis much sooner</p></li><li><p><strong>Better ML/AI</strong>: More timely data for machine learning models</p></li><li><p><strong>Competitive advantage</strong>: Faster response to business needs</p></li></ul><h3>Cost savings and benefits</h3><p>1&#65039;&#8419; <strong>Direct cost reductions</strong><br>Efficient file organization and compression lower compute and storage costs.</p><p>2&#65039;&#8419; <strong>Operational savings</strong><br>Automation reduces manual maintenance and pipeline failures, saving engineering time.</p><p>3&#65039;&#8419; <strong>Infrastructure efficiency</strong><br>Makes better use of your existing hardware while easing pressure on Hive Metastore and HDFS.</p><h4>Indirect Benefits</h4><p>1&#65039;&#8419; <strong>Faster Time-to-Market</strong><br>Teams get fresh data faster, enabling quicker feature rollouts and business decisions.</p><p>2&#65039;&#8419; <strong>Improved user experience</strong><br>Real-time features and personalization improve with fresher data and faster response to user behavior.</p><h2>What's special about their implementation?</h2><h4>Innovation: the table optimizer</h4><p>LY Corporation didn't just use Iceberg - they <strong>innovated on top of it</strong>. Their Table Optimizer is like having a smart assistant that:</p><ul><li><p>Monitors thousands of tables automatically</p></li><li><p>Predicts when maintenance is needed</p></li><li><p>Runs optimization jobs without human intervention</p></li><li><p>Prevents conflicts between different operations</p></li><li><p>Provides detailed metrics and monitoring</p></li></ul><h4>Hybrid approach</h4><p>They took a smart approach by not migrating everything at once. Stable, simple tables stayed on Hive (no need to fix what isn&#8217;t broken), while complex, dynamic tables moved to Iceberg, focusing effort where Iceberg&#8217;s features would bring the most benefit.</p><h2>Why this matters for other companies</h2><p>LY Corporation's journey shows that:</p><p><strong>1. Scale matters</strong>: At their data volumes, small improvements have huge impacts<br><strong>2. Gradual migration works</strong>: You don't need to change everything at once<br><strong>3. Automation is key</strong>: Building tools like Table Optimizer pays off<br><strong>4. Compliance is critical</strong>: Modern data platforms must support privacy regulations</p><h3>The Future</h3><p><strong>LY Corporation is continuing to:</strong></p><ul><li><p><strong>Expand Iceberg adoption</strong> to more suitable tables</p></li><li><p><strong>Improve their Table Optimizer</strong> with more intelligence</p></li><li><p><strong>Explore new Iceberg features</strong> like branching and tagging</p></li><li><p><strong>Share their learnings</strong> with the broader Apache Iceberg community</p></li></ul><h3>What makes this special</h3><p>This isn't just a story about switching technology - it's about <strong>transforming how a massive company handles data</strong>. LY Corporation proved that even with <strong>1.1 exabytes of data</strong> and <strong>100,000+ tables</strong>, you can make smart, gradual changes that deliver huge benefits.</p><p>They turned their data platform from a slow, rigid system into a <strong>fast, flexible, compliance-ready powerhouse</strong> that can adapt to whatever the future brings. And the best part? They did it without disrupting their services to 320 million users!</p><h3>Concluding thoughts</h3><p>Sometimes the biggest improvements come from making your data smarter, not just bigger. LY Corporation's Apache Iceberg journey is a perfect example of how the right technology choices can transform not just your data platform, but your entire business capability.</p><div><hr></div><p><strong>Got a project or idea?</strong></p><p><strong>Drop me a line. If it&#8217;s interesting, I&#8217;m in. If it&#8217;s weird, even better.</strong></p><p>&#128140; <strong><a href="mailto:amanguptanalytics@gmail.com">amanguptanalytics@gmail.com</a></strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.dataman.blog/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://www.dataman.blog/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[The rise of remote work and its Impact on urban life (2025): A step-by-step analysis]]></title><description><![CDATA[(DEN)]]></description><link>https://www.dataman.blog/p/the-rise-of-remote-work-and-its-impact</link><guid isPermaLink="false">https://www.dataman.blog/p/the-rise-of-remote-work-and-its-impact</guid><dc:creator><![CDATA[Aman Gupta]]></dc:creator><pubDate>Thu, 22 May 2025 05:23:44 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!3tcg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Remote work, once a temporary response to the COVID-19 pandemic, has become a defining element of the modern workforce in 2025. What began as an emergency measure has transformed how people work, live, and interact with cities. This shift profoundly reshapes urban life, altering housing trends, economic activity, infrastructure design, and social behaviors. Let&#8217;s explore how step by step.</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!3tcg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!3tcg!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 424w, https://substackcdn.com/image/fetch/$s_!3tcg!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 848w, https://substackcdn.com/image/fetch/$s_!3tcg!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!3tcg!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!3tcg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg" width="752" height="440" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:440,&quot;width&quot;:752,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34666,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://www.den.digital/i/164136964?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!3tcg!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 424w, https://substackcdn.com/image/fetch/$s_!3tcg!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 848w, https://substackcdn.com/image/fetch/$s_!3tcg!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!3tcg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40c5aaf2-cbab-4dee-8f10-75f199dedd3b_752x440.jpeg 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><div><hr></div><h3><strong>&#129489;&#8205;&#128187; 1. The remote work revolution: where we stand today.</strong></h3><p>By 2025, remote work will no longer be a perk; it will be the norm. Approximately 27% of workers with remote-capable jobs are fully remote, while 53% follow hybrid schedules, which combine home and office wo<strong>rk.</strong></p><p>The change isn&#8217;t just logistical; it&#8217;s cultural. A staggering 98% of remote workers want to continue working remotely for the rest of their careers. Companies report stable or improved productivity, and employees show higher engagement levels than those of fully in-office workers. Remote work is no longer the future; it&#8217;s the present.</p><div><hr></div><h3><strong>&#127960;&#65039; 2. Migration and housing patterns: The &#8220;Donut Effect&#8221;</strong></h3><p>The &#8220;Donut Effect&#8221; One of the most visible consequences of remote work is a shift in where people choose to live. Freed from the need to be near their offices, workers are moving away from crowded and expensive city centers to suburbs, smaller cities, and even rural areas.</p><div><hr></div><h3><strong>&#128184; 3. Economic Impact on cities and suburbs</strong></h3><p>Remote work has reshaped local economies by reducing demand in urban centers while boosting activity in suburban and rural areas. Cities that once thrived on office workers supporting restaurants, transit, and retail are seeing revenue declines, while suburbs benefit from increased spending by residents working from home.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!42y6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!42y6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 424w, https://substackcdn.com/image/fetch/$s_!42y6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 848w, https://substackcdn.com/image/fetch/$s_!42y6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 1272w, https://substackcdn.com/image/fetch/$s_!42y6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!42y6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png" width="736" height="441" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:441,&quot;width&quot;:736,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:220490,&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;:&quot;https://www.den.digital/i/164136964?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!42y6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 424w, https://substackcdn.com/image/fetch/$s_!42y6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 848w, https://substackcdn.com/image/fetch/$s_!42y6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.png 1272w, https://substackcdn.com/image/fetch/$s_!42y6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4c973c58-af5e-49e0-8c3f-cc94b19d6c3e_736x441.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><div><hr></div><h3><strong>4. Social and environmental implications</strong></h3><p>Remote work offers undeniable benefits, such as better work-life balance, flexibility, and reduced commute stress. However, it also introduces risks, such as social isolation and blurred boundaries between personal and work life. From a diversity and inclusion standpoint, remote work has opened doors for individuals who previously faced barriers, including those with disabilities and members of underserved communities.</p><div><hr></div><h3><strong>&#9888;&#65039; 5. Challenges and the road ahead</strong></h3><p>Despite the positives, challenges remain.</p><ul><li><p>Urban inequality: Service workers are dependent on downtown foot traffic. Cleaners, food vendors, and retail clerks face job insecurity as cities empty.</p></li><li><p>Digital divide: Not everyone has reliable internet access or the digital literacy needed to participate in the remote economy.</p></li><li><p>Policy gaps: Cities must act now to support urban and suburban growth. This means investing in broadband, revising zoning laws, and reimagining city design<strong> </strong>for a hybrid workforce.</p><p></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_!8Cen!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!8Cen!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Cen!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Cen!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Cen!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!8Cen!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg" width="580" height="326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:326,&quot;width&quot;:580,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:80323,&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;:&quot;https://www.den.digital/i/164136964?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!8Cen!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 424w, https://substackcdn.com/image/fetch/$s_!8Cen!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 848w, https://substackcdn.com/image/fetch/$s_!8Cen!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!8Cen!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff48cdab0-4973-4e96-953e-ca81289e2a51_580x326.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><div><hr></div><h3><strong>Conclusion:</strong></h3><p>As remote work redefines how and where we live and work, cities and suburbs must adapt quickly to evolving economic and social dynamics. The shift presents opportunities for greater flexibility and inclusivity, as well as challenges that demand thoughtful policy and infrastructure responses. Navigating this transformation will be crucial to shaping resilient, equitable urban futures.</p><div><hr></div><p><strong>Do you have a project or idea?</strong></p><p><strong>Feel free to drop me a line. If it&#8217;s interesting, I&#8217;m in if it&#8217;s weird, even better.</strong></p><p>&#128140; <strong><a href="mailto:amanguptanalytics@gmail.com">amanguptanalytics@gmail.com</a></strong></p><p></p>]]></content:encoded></item><item><title><![CDATA[Stop creating mediocre AI content: 5 cognitive workflow secrets for game-changing results.]]></title><description><![CDATA[(DEN)]]></description><link>https://www.dataman.blog/p/stop-creating-mediocre-ai-content</link><guid isPermaLink="false">https://www.dataman.blog/p/stop-creating-mediocre-ai-content</guid><dc:creator><![CDATA[Aman Gupta]]></dc:creator><pubDate>Thu, 10 Apr 2025 07:44:49 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!UaAF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Getting good content out of AI isn&#8217;t just a matter of smashing a button and shouting, "Go, a magic robot, go!" You&#8217;ve gotta put some thought into it. Time, focus, and probably a strong cup of coffee to keep up. &#9749;</p><p>Sure, you've got ChatGPT, Claude, Gemini, and even Copilot lined up like a dream team of robot interns. But if everything the AI spits out sounds robotic and lifeless, you&#8217;re not alone. It&#8217;s not that the AI is broken. It&#8217;s just missing a decent content architect to guide the way.</p><p>As Josh Wills might say, with a few strategic tweaks, we can go from meh to marvelous. Here are five ways to improve your AI-generated content.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UaAF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UaAF!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!UaAF!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!UaAF!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!UaAF!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UaAF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:2170878,&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;:&quot;https://www.den.digital/i/161000398?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!UaAF!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 424w, https://substackcdn.com/image/fetch/$s_!UaAF!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 848w, https://substackcdn.com/image/fetch/$s_!UaAF!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!UaAF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0697af7-b801-487a-bf1b-a1dccd09c83b_1536x1024.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><h2>1. <strong>Stop telling your AI model to &#8220;just write something&#8221;</strong> &#9997;&#65039;</h2><p>If your prompt is "Write about X," don&#8217;t be surprised when the result sounds like a high school book report. One-line prompts get you one-dimensional results.</p><p>Be specific. Seriously:</p><ul><li><p>Who&#8217;s it for? &#127919;</p></li><li><p>What&#8217;s the tone? &#128483;&#65039;</p></li><li><p>How should it look? &#128444;&#65039;</p></li></ul><p>Example: &#8220;For data engineers. Witty. Three short paras. End with bullets.&#8221;</p><p>Better yet:</p><ul><li><p>Show a sample</p></li><li><p>Ask for options</p></li></ul><p>The model&#8217;s not magic. It&#8217;s just really good autocomplete with a PhD. Guide it like you mean it.</p><p>For example, compare these two:</p><ul><li><p>&#8220;Write a blog post about prompt engineering.&#8221;</p></li><li><p>&#8220;Write a 300-word post for junior data engineers explaining prompt engineering using a cooking metaphor. Make it witty, and start with a bad example.&#8221;</p></li></ul><p>The second gets you usable content. The first gets you oatmeal.</p><div><hr></div><h2>2. <strong>Winging it is not a strategy</strong> &#128747;</h2><p>Starting without a plan? That&#8217;s the quickest way to write 800 words of structured nonsense.</p><p>Take five minutes. Make an outline.</p><ul><li><p>Yes, the AI can help you build one.</p></li><li><p>No, it won&#8217;t know what matters until <em>you</em> do.</p></li></ul><p>Even a few quick bullets or a rough flow sketch is enough. Then let Claude or ChatGPT do their thing.</p><p>Remember:</p><ul><li><p>Good outlines don&#8217;t have to be good. They just have to exist.</p></li><li><p>You can fix a rough draft. You can&#8217;t fix a blank one.</p></li></ul><p>Plan first. Generate second. Edit last. &#128257;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MV9Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MV9Q!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 424w, https://substackcdn.com/image/fetch/$s_!MV9Q!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 848w, https://substackcdn.com/image/fetch/$s_!MV9Q!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!MV9Q!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MV9Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png" width="1024" height="1536" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1536,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:3526372,&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;:&quot;https://www.den.digital/i/161000398?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!MV9Q!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 424w, https://substackcdn.com/image/fetch/$s_!MV9Q!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 848w, https://substackcdn.com/image/fetch/$s_!MV9Q!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.png 1272w, https://substackcdn.com/image/fetch/$s_!MV9Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcf0fc3b2-2611-4de4-9da6-662c6350bf21_1024x1536.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>It&#8217;s not magic. It&#8217;s just a process.</p><div><hr></div><h2>3. <strong>One-shot drafts are how bad takes happen</strong> &#129513;</h2><p>Asking your AI to write the entire piece in one go? That&#8217;s like asking it to cook dinner, do the dishes, and fold your laundry at the same time. It&#8217;ll try, but the results will be mushy.</p><p>Try this instead:</p><ul><li><p><strong>Chunk it. Always.</strong></p></li><li><p>Don&#8217;t dump the whole task on the model at once.</p></li></ul><p>Why?</p><ul><li><p>That&#8217;s how you get generic tone, fuzzy logic, and zero edge.</p></li><li><p>Start small: begin with the intro.</p></li><li><p>Read it. Fix it.</p></li><li><p>Then move on to the next part.</p></li><li><p>Section by section. Small asks. Tight feedback loops. &#128260;</p></li></ul><p>The more you focus, the better it sounds. Clarity scales with constraint.</p><p>Think of it like a relay race, not a solo sprint:</p><p><strong>Outline &#8594; Section &#8594; Review &#8594; Iterate</strong></p><p>This keeps the narrative tight, and your sanity intact.</p><div><hr></div><h2>4. <strong>Don&#8217;t skip the edit: POLISH, POLISH, POLISH</strong> &#10024;</h2><p>Here&#8217;s where the magic actually happens: editing.</p><p>This is your time to shine: tighten the logic, add a clever turn of phrase, or kill the fluff with precision.</p><p>Hit &#8220;generate&#8221; and walk away? Don&#8217;t be shocked when it reads like something written by, well, a robot.</p><p>Time to take off autopilot and step in as editor-in-chief. &#129504;</p><p>Start with:</p><ul><li><p>Fixing clunky phrasing</p></li><li><p>Spotting logic gaps</p></li><li><p>Smoothing transitions</p></li><li><p>Making sure the tone doesn&#8217;t zigzag from Slack joke to corporate keynote</p></li></ul><p>The goal isn&#8217;t perfection. It&#8217;s flow, with a bit of flavor.</p><p>Drop in a metaphor. Chop a paragraph in half. Rebuild a sentence so it actually makes sense.</p><p>This is where your voice shows up. It&#8217;s also where most AI content quietly crumbles if you skip it.</p><p>Golden rule: if it <em>sounds</em> like a machine wrote it, it&#8217;s not done. One edit makes it better. Two? That&#8217;s when the good stuff hits.</p><div><hr></div><h2>5. <strong>Your AI wrote it. Now make it sound like you did.</strong> &#127908;</h2><p>Just because AI lent a hand doesn&#8217;t mean it has to read like instructions on assembling IKEA furniture.</p><p>Bland content is background noise. Your voice is the signal. &#128225;</p><p>So punch it up:</p><ul><li><p>Crack a joke.</p></li><li><p>Toss in a metaphor.</p></li><li><p>Mention something your audience <em>actually</em> gets. Bonus points if it&#8217;s not from a case study.</p></li></ul><p>Prompt with intent: <em>"Write with the snark of Josh Wills and the clarity of an O&#8217;Reilly book."</em> Suddenly, your model has a compass instead of a blindfold.</p><p>Still feels off? No problem:</p><ul><li><p>Ask for three takes in different voices: snappy, serious, playful.</p></li><li><p>Feed in writing samples you like: Josh Wills, Lex Fridman, Ali Abdaal, Douglas Adams. Let the model riff.</p></li></ul><p>When one lands, lock in the tone. Apply it section by section.</p><p>A single sharp analogy can turn a forgettable paragraph into the line people quote back to you.</p><p>If your AI-written blog reads like corporate onboarding docs, it deserves to be ignored. Set the bar higher than &#8220;not embarrassing.&#8221;</p><p>Boring fades. Voice lasts. Make yours count.</p><div><hr></div><h2>6. Bonus: <strong>Use Feedback Loops &#8211; Don&#8217;t create in a vacuum</strong> &#128257;</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ZvbO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ZvbO!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!ZvbO!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!ZvbO!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!ZvbO!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ZvbO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1242255,&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;:&quot;https://www.den.digital/i/161000398?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!ZvbO!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!ZvbO!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!ZvbO!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!ZvbO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3170f71b-a987-4199-bdc6-6aa175347613_1024x1024.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>Critique your content.</p><p>It&#8217;s not a common practice, but it&#8217;s a best one. Ask AI to critique your content and tell how it scores and what the weak areas are. For example, I use a GPT with books from Seth Godin and Chip Heath in it. And I ask it something like:</p><p>"Critique my content according to principles of Seth Godin and Chip Heath. Tell me what works best and what can be improved. Give the current article a score for likely performance."</p><p>And then paste the article in.</p><p>Simple, right? But very effective. It lets you quickly vet your draft so that poor quality doesn&#8217;t creep in.</p><p>Great creators seek feedback. After drafting, don&#8217;t just hit publish. Put your content through a feedback wringer. Ask a colleague or friend to tear it apart (better them than your readers). Or use the AI itself as a critic: have ChatGPT analyze Claude&#8217;s output or vice versa and see what weaknesses they spot.</p><p>Often, I&#8217;ll prompt the AI with:</p><p>"Critique the above and suggest improvements."</p><p>&#8211; and you&#8217;ll get surprisingly useful editing suggestions.</p><p>Another pro move: read your content</p><p><strong>out loud</strong> &#128266;</p><p>(or use a text-to-speech tool) to catch awkward phrasing or pacing issues. If you stumble while reading, that part needs fixing.</p><p>Some folks even record themselves giving feedback and feed that back into the AI to implement changes. Also, leverage your community. Drop a snippet in your team&#8217;s Slack channel for quick reactions.</p><p>The point is to create a feedback loop between you, AI, and real humans to refine the content. Iteration isn&#8217;t a sign your first try was bad. It&#8217;s how you <strong>make good content great</strong>.</p><div><hr></div><h2>Conclusion</h2><p>AI moves fast, and tools change weekly. What matters is how you use them. Try new prompts, automate the boring parts, and fine-tune models for your writing. Watch what works, double down, and cut the rest.</p><p>Mediocre AI content is a choice. With the right workflow, you&#8217;re not just creating. You&#8217;re compounding. So iterate, measure, and improve. Now stop reading and make something worth sharing. &#128640;</p><div><hr></div><p><strong>Got a project or idea?</strong></p><p><strong>Drop me a line. If it&#8217;s interesting, I&#8217;m in. If it&#8217;s weird, even better.</strong></p><p>&#128140; <strong><a href="mailto:amanguptanalytics@gmail.com">amanguptanalytics@gmail.com</a></strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.dataman.blog/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://www.dataman.blog/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item></channel></rss>