title: In a Self Join, Remove Line with the same ID
body: <p>My Code.</p>
  <p>This is to join mistake done by employees when creating Credit Documet References the &quot;Link&quot; is what join them together but the credit &quot;Doc_ref&quot; are normally the same but sometime 2 are created splitting the Credits.</p>
  <p>I use the Doc_ref to View any returns linked to it. so that's my dilemma</p>
  <pre><code>SELECT DISTINCT A.LINE_ID, CASE
      WHEN  POSITIVE.Doc_Ref = B.Link AND A.Link = B.Link AND A.Doc_Ref != B.Doc_Ref AND A.Principal_Ref != B.Principal_Ref AND A.Outlet_Name = B.Outlet_Name  THEN rtrim(A.[Doc_Ref]) + ' | ' + rtrim(B.[Doc_Ref]) 
      ELSE A.Doc_Ref
  END AS Doc_Ref,
   A.Glue_Code, A.CCN_Name,  A.Doc_Date, A.Outlet_Code, A.Outlet_Name, 
  A.Link, A.Principal_Ref
  
  FROM NEGITIVE A, NEGITIVE B, POSITIVE WHERE A.Doc_Ref != B.Doc_Ref AND A.Link = B.Link  ORDER BY Doc_Ref
  </code></pre>
  <p>My Result</p>
  <pre><code>474 ABP0008918 | ABP0008919 GPT05610    PTA 2021-05-04  15078428 
  474 ABP0008918 GPT05610    PTA 2021-05-04  15078428 
  475 ABP0008919 | ABP0008918 GPT05610    PTA 2021-05-04  15078428 
  475 ABP0008919 GPT05610    PTA 2021-05-04  15078428
  </code></pre>
  <p>What I would like to see is Just</p>
  <pre><code>474 ABP0008918 | ABP0008919 GPT05610    PTA 2021-05-04  15078428  
  475 ABP0008918 | ABP0008919 GPT05610    PTA 2021-05-04  15078428                                                                                                                                                                                                                                        
  </code></pre>
  <p>Note that the Doc_Ref must look the same after the query is completed.</p>
  <p>Thank you.</p>