title: Select the first row in a join of two tables in one statement
body: <p>I need to select only the first row from a query that joins tables A and B. On table B exist multiple records with same name. There are not identifiers in any of the two tables. I cannot change the scheme either because I do not own the DB.</p>
  
  <pre><code>TABLE A
  NAME
  
  TABLE B
  NAME
  DATA1
  DATA2
  
  Select Distinct A.NAME,B.DATA1,B.DATA2 
  From A 
  Inner Join B on A.NAME = B.NAME
  </code></pre>
  
  <p>This gives me</p>
  
  <pre><code>NAME       DATA1    DATA2
  sameName   1        2
  sameName   1        3
  otherName  5        7
  otherName  8        9
  </code></pre>
  
  <p>but I need to retrieve only one row per name</p>
  
  <pre><code>NAME       DATA1    DATA2
  sameName   1        2
  otherName  5        7
  </code></pre>
  
  <p>I was able to do this by adding the result into a temp table with a identity column and then select the minimum id per name. </p>
  
  <p>The problem here is that I require to do this in one single statement.</p>