<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unexpected Duplicates in SQL Query in Data Warehouse</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699356#M3049</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1274372" data-lia-user-login="Ornella" class="lia-mention lia-mention-user"&gt;Ornella&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;Unexpected duplicates usually show up when your JOIN brings in more rows than expected—especially if the table you're joining to has multiple matching rows.&lt;/P&gt;&lt;P&gt;A couple of things to check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Are you joining on a &lt;STRONG&gt;unique key&lt;/STRONG&gt;? If not, even a small mismatch can cause row multiplication.&lt;/LI&gt;&lt;LI&gt;Try using DISTINCT or GROUP BY to see if that helps reduce the duplicates—but that’s more of a patch than a fix.&lt;/LI&gt;&lt;LI&gt;You can also use ROW_NUMBER() or RANK() to filter down to just one row per group if needed.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If you can share a simplified version of your query and table structure, happy to take a closer look!&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 20 May 2025 06:08:38 GMT</pubDate>
    <dc:creator>burakkaragoz</dc:creator>
    <dc:date>2025-05-20T06:08:38Z</dc:date>
    <item>
      <title>Unexpected Duplicates in SQL Query</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4698181#M3042</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Could someone please explain why I'm getting duplicate values even though my query is supposed to prevent them? And if possible, suggest a solution to fix it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ornella&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 09:54:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4698181#M3042</guid>
      <dc:creator>Ornella</dc:creator>
      <dc:date>2025-05-19T09:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Duplicates in SQL Query</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699016#M3046</link>
      <description>&lt;P&gt;Isn't your query equivalent to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DELETE FROM XXXX_CTRL_CARD&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHERE CAST(DATE_EXEC as DATE) &amp;lt;= GETDATE()&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;?&lt;/P&gt;</description>
      <pubDate>Mon, 19 May 2025 20:20:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699016#M3046</guid>
      <dc:creator>lutz_bendlin</dc:creator>
      <dc:date>2025-05-19T20:20:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Duplicates in SQL Query</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699356#M3049</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1274372" data-lia-user-login="Ornella" class="lia-mention lia-mention-user"&gt;Ornella&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;Unexpected duplicates usually show up when your JOIN brings in more rows than expected—especially if the table you're joining to has multiple matching rows.&lt;/P&gt;&lt;P&gt;A couple of things to check:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Are you joining on a &lt;STRONG&gt;unique key&lt;/STRONG&gt;? If not, even a small mismatch can cause row multiplication.&lt;/LI&gt;&lt;LI&gt;Try using DISTINCT or GROUP BY to see if that helps reduce the duplicates—but that’s more of a patch than a fix.&lt;/LI&gt;&lt;LI&gt;You can also use ROW_NUMBER() or RANK() to filter down to just one row per group if needed.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;If you can share a simplified version of your query and table structure, happy to take a closer look!&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 20 May 2025 06:08:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699356#M3049</guid>
      <dc:creator>burakkaragoz</dc:creator>
      <dc:date>2025-05-20T06:08:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Duplicates in SQL Query</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699563#M3053</link>
      <description>&lt;P&gt;&lt;FONT size="3"&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="1274372" data-lia-user-login="Ornella" class="lia-mention lia-mention-user"&gt;Ornella&lt;/a&gt;&amp;nbsp;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Thank you for reaching out to Microsoft Fabric Community Forum.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="529075" data-lia-user-login="burakkaragoz" class="lia-mention lia-mention-user"&gt;burakkaragoz&lt;/a&gt;&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="945037" data-lia-user-login="lutz_bendlin" class="lia-mention lia-mention-user"&gt;lutz_bendlin&lt;/a&gt;&amp;nbsp;Thank you for your quick response.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;Could you please try the below SQL query:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;WITH CTE AS (&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT *,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ROW_NUMBER() OVER (PARTITION BY CAST(DATE_EXEC AS DATE) ORDER BY DATE_EXEC DESC) AS rn&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM XXXX_CTRL_CARD&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE CAST(DATE_EXEC AS DATE) = CAST(GETDATE() AS DATE)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="3"&gt;DELETE FROM CTE WHERE rn &amp;gt; 1;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV style="direction: ltr;"&gt;
&lt;TABLE style="direction: ltr; border-collapse: collapse; border: 1pt solid #A3A3A3;" title="" border="1" summary="" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD style="background-color: #c5e0b3; vertical-align: top; width: 7.5284in; padding: 4pt 4pt 4pt 4pt; border: 1pt solid #A3A3A3;"&gt;
&lt;H4 style="margin: 0in; font-family: Calibri; font-size: 12.0pt;"&gt;&lt;SPAN&gt;If this post helps, then please consider &lt;/SPAN&gt;&lt;SPAN&gt;Accepting&lt;/SPAN&gt;&lt;SPAN&gt; as solution&lt;/SPAN&gt;&lt;SPAN&gt; to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!&lt;/SPAN&gt;&lt;/H4&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;P style="margin: 0in; margin-left: 3.0in; font-family: Arial; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: Arial; font-size: 11.0pt;"&gt;B Manikanteswara Reddy&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 07:28:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699563#M3053</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-05-20T07:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unexpected Duplicates in SQL Query</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699609#M3054</link>
      <description>&lt;P&gt;Hello&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you for your prompt response. I had already implemented it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Ornella&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 07:55:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Warehouse/Unexpected-Duplicates-in-SQL-Query/m-p/4699609#M3054</guid>
      <dc:creator>Ornella</dc:creator>
      <dc:date>2025-05-20T07:55:00Z</dc:date>
    </item>
  </channel>
</rss>

