title: SQL update table with distinct
body: <p>is it possible to do an update to table with Distinct statement? I have a query here that will map the entries from another table but table1 have duplicate entries. removing the distinct statement made the output wrong.</p>
  
  <pre><code>select distinct dm.[EE],dm.document_name,lu.*
  from Table1 as dm 
  left join Table2 as lu on lu.[document_name]=dm.document_name
  where Doc_Count=2
  </code></pre>
  
  <p>I made a sample scenario in sql fiddle. (<a href="http://sqlfiddle.com/#!6/634ef/1" rel="nofollow noreferrer">http://sqlfiddle.com/#!6/634ef/1</a>)</p>
  
  <pre><code>CREATE TABLE TABLE1
      ([EE] int, [Name] nvarchar(50),[Doc_Count] int, [document_name] nvarchar(50), [orginal_name] nvarchar(50));
  
  INSERT INTO TABLE1
      ([EE], [Name],[Doc_Count], [document_name])
  VALUES
      (001, 'Employee 1','2','Admin123.pdf'),
      (001, 'Employee 1','2', 'Admin123.pdf'),
      (002, 'Employee 2','2', 'password.pdf'),
      (002, 'Employee 2','2', 'password.pdf')
  
  
  CREATE TABLE TABLE2
      ([document_name] nvarchar(50), [original_name] nvarchar(50));
  
  INSERT INTO TABLE2
      ([document_name], [original_name])
  VALUES
      ('Admin123.pdf','test444.pdf'),
      ('Admin123.pdf','test0124.pdf'),
      ('password.pdf','hello1.pdf'),
      ('password.pdf','hello2.pdf')
  </code></pre>
  
  <p>Results table:</p>
  
  <pre><code>EE  document_name   document_name   original_name
  1   Admin123.pdf    Admin123.pdf    test0124.pdf
  1   Admin123.pdf    Admin123.pdf    test444.pdf
  2   password.pdf    password.pdf    hello1.pdf
  2   password.pdf    password.pdf    hello2.pdf
  </code></pre>