title: Getting “No column was specified for column 1" when joining a derived table
body: <p>I am writing a <code>left join</code> and getting a </p>
  
  <blockquote>
    <p>No column was specified for column 1" error. </p>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>LEFT JOIN 
  (
     SELECT  CASE WHEN COUNT(*) &gt; 1 THEN '' ELSE mycolumn END
     FROM 
      (
          SELECT code_value 
          FROM allocation 
          WHERE allocation.id='[val]'
          GROUP BY code_value
      ) grp
     GROUP BY code_value
  ) AS code4table
  ON code4table.itemid = table1.id
  </code></pre>
  
  <p>I want to return code_value value if all values are same else return ''
  I am guessing I also need to include the <code>code4table.itemid</code> in my select query but not sure how.</p>
  
  <p>Thanks in advance for the help.</p>