title: How do I just get the first matching row?
body: <p>I have a fairly complex SQL query - part of which requires to look up a company_ID value found in the first table to obtain the company_Name in the second table. The second table may have variants of the company name, but that is OK - I just need the first match.</p>
  
  <p>So, tableA looks something like this (approx 2 dozen columns and many rows)</p>
  
  <pre><code>company_ID (CHAR(12))
  161012348876
  561254435253
  103929478273
  141567643542
  </code></pre>
  
  <p>tableB looks something like this</p>
  
  <pre><code>company_ID (Integer) Company_name
  161012348876         Watson &amp; Jones Ltd
  161012348876         Watson and Jones
  561254435253         Fictional Co. plc
  103929478273         Made Up Corp.
  161012348876         Watson Jones Ltd
  141567643542         Thingymajig Gmbh.
  </code></pre>
  
  <p>This query will return multiple rows for 161012348876. What're good ways just to get one row returned for each matching company_id (i.e. 4 rows instead of 6)?</p>
  
  <pre><code>SELECT *, t2.company_name
  FROM tableA t1
  
  JOIN tableB t2 ON t1.company_id = cast(t2.company_id as CHAR(12))
  </code></pre>
  
  <p>I am using Teradata SQL.</p>
  
  <p>Any help much appreciated.</p>