title: SQL Left Join first match only
body: <p>I have a query against a large number of big tables (rows and columns) with a number of joins, however one of tables has some duplicate rows of data causing issues for my query. Since this is a read only realtime feed from another department I can't fix that data, however I am trying to prevent issues in my query from it.</p>
  
  <p>Given that, I need to add this crap data as a left join to my good query. The data set looks like:</p>
  
  <pre><code>IDNo    FirstName   LastName    ...
  -------------------------------------------
  uqx     bob     smith
  abc     john        willis
  ABC     john        willis
  aBc     john        willis
  WTF     jeff        bridges
  sss     bill        doe
  ere     sally       abby
  wtf     jeff        bridges
  ...
  </code></pre>
  
  <p>(about 2 dozen columns, and 100K rows)</p>
  
  <p>My first instinct was to perform a distinct gave me about 80K rows:</p>
  
  <pre><code>SELECT DISTINCT P.IDNo
  FROM people P
  </code></pre>
  
  <p>But when I try the following, I get all the rows back:</p>
  
  <pre><code>SELECT DISTINCT P.*
  FROM people P
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>SELECT 
      DISTINCT(P.IDNo) AS IDNoUnq 
      ,P.FirstName
      ,P.LastName
      ...etc.    
  FROM people P
  </code></pre>
  
  <p>I then thought I would do a FIRST() aggregate function on all the columns, however that feels wrong too. Syntactically am I doing something wrong here?</p>
  
  <p><strong>Update:</strong>
  Just wanted to note: These records are duplicates based on a non-key / non-indexed field of ID listed above. The ID is a text field which although has the same value, it is a different case than the other data causing the issue.</p>