<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Durgesh Yadav</title>
    <description>The latest articles on DEV Community by Durgesh Yadav (@analyticsdurgesh).</description>
    <link>https://dev.to/analyticsdurgesh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4141317%2F1b5fb39b-0e66-448a-9497-e215a41f19b0.jpg</url>
      <title>DEV Community: Durgesh Yadav</title>
      <link>https://dev.to/analyticsdurgesh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/analyticsdurgesh"/>
    <language>en</language>
    <item>
      <title>this is something mostly everyone goes through!</title>
      <dc:creator>Durgesh Yadav</dc:creator>
      <pubDate>Fri, 25 Sep 2026 07:12:42 +0000</pubDate>
      <link>https://dev.to/analyticsdurgesh/this-is-something-mostly-everyone-goes-through-19ni</link>
      <guid>https://dev.to/analyticsdurgesh/this-is-something-mostly-everyone-goes-through-19ni</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka" class="crayons-story__hidden-navigation-link"&gt;5 SQL patterns that run fine and still return the wrong answer&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/analyticsdurgesh" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4141317%2F1b5fb39b-0e66-448a-9497-e215a41f19b0.jpg" alt="analyticsdurgesh profile" class="crayons-avatar__image" width="460" height="460"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/analyticsdurgesh" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Durgesh Yadav
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Durgesh Yadav
                
                
              
              &lt;div id="story-author-preview-content-4738576" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/analyticsdurgesh" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4141317%2F1b5fb39b-0e66-448a-9497-e215a41f19b0.jpg" class="crayons-avatar__image" alt="" width="460" height="460"&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Durgesh Yadav&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Sep 25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka" id="article-link-4738576"&gt;
          5 SQL patterns that run fine and still return the wrong answer
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/career"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;career&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/dataengineering"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;dataengineering&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/sql"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;sql&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/beginners"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;beginners&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
          &lt;a href="https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left"&gt;
            &lt;div class="multiple_reactions_aggregate"&gt;
              &lt;span class="multiple_reactions_icons_container"&gt;
                  &lt;span class="crayons_icon_container"&gt;
                    &lt;img src="https://assets.dev.to/assets/sparkle-heart-5f9bee3767e18deb1bb725290cb151c25234768a0e9a2bd39370c382d02920cf.svg" width="24" height="24"&gt;
                  &lt;/span&gt;
              &lt;/span&gt;
              &lt;span class="aggregate_reactions_counter"&gt;1&lt;span class="hidden s:inline"&gt;&amp;nbsp;reaction&lt;/span&gt;&lt;/span&gt;
            &lt;/div&gt;
          &lt;/a&gt;
            &lt;a href="https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              

              &lt;span class="hidden s:inline"&gt;Add&amp;nbsp;Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            4 min read
          &lt;/small&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
    </item>
    <item>
      <title>5 SQL patterns that run fine and still return the wrong answer</title>
      <dc:creator>Durgesh Yadav</dc:creator>
      <pubDate>Fri, 25 Sep 2026 05:40:42 +0000</pubDate>
      <link>https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka</link>
      <guid>https://dev.to/analyticsdurgesh/5-sql-patterns-that-run-fine-and-still-return-the-wrong-answer-40ka</guid>
      <description>&lt;p&gt;A database table is really just a spreadsheet. Rows are records — one row&lt;br&gt;
per customer, one row per order. Columns are the fields — a name, a date,&lt;br&gt;
an amount. SQL is the language you use to ask that spreadsheet questions:&lt;br&gt;
show me these rows, combine these two sheets, add these up.&lt;/p&gt;

&lt;p&gt;The five things below aren't about learning more SQL words. They're about&lt;br&gt;
five specific moments where a question you ask gets answered technically&lt;br&gt;
correctly, but not in the way you meant — and nothing warns you. No error&lt;br&gt;
message. Just a wrong number that looks right.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Asking for "everyone" and getting "only some people"
&lt;/h2&gt;

&lt;p&gt;Say you have a table of customers and a table of orders. You want a list&lt;br&gt;
of every customer, showing their order if they have one, and nothing if&lt;br&gt;
they don't — because you still want to see the customers with no orders.&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
SELECT c.customer_id, o.order_id&lt;br&gt;
FROM customers c&lt;br&gt;
LEFT JOIN orders o ON c.customer_id = o.customer_id&lt;br&gt;
WHERE o.order_date &amp;gt;= '2026-01-01';&lt;/p&gt;

&lt;p&gt;The LEFT JOIN part does say "keep everyone from the customers list."&lt;br&gt;
But the WHERE line underneath quietly overrides it. Here's why: a&lt;br&gt;
customer with no order gets a blank (called NULL) where their order date&lt;br&gt;
would be. And "is this blank date after 1 January" doesn't have a yes or&lt;br&gt;
no answer — it's neither true nor false, it's just undefined. SQL treats&lt;br&gt;
undefined the same as no, so that customer gets thrown out.&lt;/p&gt;

&lt;p&gt;You asked for everyone. You got only the people who also happen to have a&lt;br&gt;
recent order. Nothing crashed. Nothing warned you. The list is just&lt;br&gt;
quietly shorter than you think it is.&lt;/p&gt;

&lt;p&gt;The picture makes this easier to see than the sentence does:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc3qoj94sw73gs0qw8uf2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc3qoj94sw73gs0qw8uf2.png" alt="How a LEFT JOIN quietly turns into an INNER JOIN" width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The fix is to move the date condition up into the matching step instead&lt;br&gt;
of the filtering step:&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
LEFT JOIN orders o&lt;br&gt;
  ON c.customer_id = o.customer_id&lt;br&gt;
  AND o.order_date &amp;gt;= '2026-01-01'&lt;/p&gt;

&lt;p&gt;Now the date check only decides which order to attach, not whether the&lt;br&gt;
customer gets kept.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A "give me everyone except these people" list that comes back empty
&lt;/h2&gt;

&lt;p&gt;sql&lt;br&gt;
SELECT * FROM customers&lt;br&gt;
WHERE customer_id NOT IN (SELECT customer_id FROM cancelled_orders);&lt;/p&gt;

&lt;p&gt;Plain English: show me every customer who isn't in the cancelled-orders&lt;br&gt;
list. Reasonable ask.&lt;/p&gt;

&lt;p&gt;Here's the trap. If even one row in cancelled_orders has a blank&lt;br&gt;
customer_id — maybe a cancellation that was logged before anyone was&lt;br&gt;
assigned to it — the whole comparison breaks. SQL can't say "is this&lt;br&gt;
customer definitely not equal to a blank," so it refuses to say yes for&lt;br&gt;
anyone at all. The entire result becomes empty, for a reason that has&lt;br&gt;
nothing to do with your actual customers.&lt;/p&gt;

&lt;p&gt;Swap it for asking the question a different way — not "is my ID absent&lt;br&gt;
from that list," but "does a cancelled order exist for me":&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
SELECT * FROM customers c&lt;br&gt;
WHERE NOT EXISTS (&lt;br&gt;
  SELECT 1 FROM cancelled_orders x&lt;br&gt;
  WHERE x.customer_id = c.customer_id&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;This version isn't confused by a blank value sitting somewhere else in&lt;br&gt;
the list. If you don't know for certain that a column can never contain a&lt;br&gt;
blank, treat this as the safer way to ask the question.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Two ways of counting that quietly disagree
&lt;/h2&gt;

&lt;p&gt;sql&lt;br&gt;
SELECT COUNT(*) AS all_rows, COUNT(phone_number) AS with_phone&lt;br&gt;
FROM customers;&lt;/p&gt;

&lt;p&gt;Counting sounds like it should only have one right answer. It doesn't.&lt;br&gt;
COUNT(*) counts every row, full stop. COUNT(phone_number) counts only&lt;br&gt;
the rows where that specific field actually has something in it —&lt;br&gt;
blanks don't get counted.&lt;/p&gt;

&lt;p&gt;If those two numbers come back different, that gap is telling you exactly&lt;br&gt;
how many customers have no phone number on file. It's a genuinely useful&lt;br&gt;
one-line check for "how messy is this data" before you build anything&lt;br&gt;
more complicated on top of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Adding things up in order, and getting the order wrong
&lt;/h2&gt;

&lt;p&gt;sql&lt;br&gt;
SELECT&lt;br&gt;
  order_date,&lt;br&gt;
  SUM(daily_revenue) OVER (ORDER BY order_date) AS running_total&lt;br&gt;
FROM daily_sales;&lt;/p&gt;

&lt;p&gt;This is meant to build a running total — day one's number, then day one&lt;br&gt;
plus day two, then day one plus two plus three, and so on. Most of the&lt;br&gt;
time it does exactly that.&lt;/p&gt;

&lt;p&gt;The exception: if two rows share the exact same date, some databases&lt;br&gt;
default to treating tied dates as one combined step rather than adding&lt;br&gt;
them one at a time. Your running total can jump differently than expected&lt;br&gt;
right at the point where a date repeats, and it's easy to miss because&lt;br&gt;
the rest of the total looks completely normal.&lt;/p&gt;

&lt;p&gt;Being explicit fixes it:&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
SUM(daily_revenue) OVER (&lt;br&gt;
  ORDER BY order_date&lt;br&gt;
  ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW&lt;br&gt;
)&lt;/p&gt;

&lt;p&gt;This spells out "add strictly one row at a time," which removes the&lt;br&gt;
ambiguity about what to do with ties.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. A family tree that's missing the person at the top
&lt;/h2&gt;

&lt;p&gt;sql&lt;br&gt;
SELECT e.employee_name, m.employee_name AS manager_name&lt;br&gt;
FROM employees e&lt;br&gt;
JOIN employees m ON e.manager_id = m.employee_id;&lt;/p&gt;

&lt;p&gt;This is a table joined to itself, to line up each employee with their&lt;br&gt;
manager's name. It works for almost everyone — except whoever has no&lt;br&gt;
manager at all, like the CEO or the founder. That one row has a blank&lt;br&gt;
where the manager should be, and a plain join treats a blank as "doesn't&lt;br&gt;
match," so that person disappears from the results entirely.&lt;/p&gt;

&lt;p&gt;You'll get a org chart that looks complete and is quietly missing exactly&lt;br&gt;
one row — the one at the very top.&lt;/p&gt;

&lt;p&gt;sql&lt;br&gt;
LEFT JOIN employees m ON e.manager_id = m.employee_id&lt;/p&gt;

&lt;p&gt;Same lesson as the very first pattern: whenever a match can land on a&lt;br&gt;
blank, start with LEFT and only switch to a plain join once you're sure&lt;br&gt;
you want to lose that row on purpose.&lt;/p&gt;

&lt;p&gt;Every one of these has the same shape. Something in the data is blank,&lt;br&gt;
or two rows tie, and the ordinary-sounding question you asked gets&lt;br&gt;
answered in a way that's technically consistent but not what you meant.&lt;br&gt;
None of it shows up as an error. It shows up as a number that's wrong in&lt;br&gt;
a way nobody notices until later.&lt;/p&gt;

&lt;p&gt;More worked examples like these, free to browse with no signup, are at&lt;br&gt;
the &lt;a href="https://www.prepnplaced.com/prepnplaced-notes" rel="noopener noreferrer"&gt;https://www.prepnplaced.com/prepnplaced-notes&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>career</category>
      <category>dataengineering</category>
      <category>sql</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
