title: Invalid table alias or column reference b
body: <p>What's wrong with this query (running in hive):</p>
  
  <pre><code>SELECT count(*) TotalCount, b.region_code
  from XXX a
  INNER JOIN YYY b
  ON a.uid=b.uid
  where a.dt = '2015-04-15'
  group by b.region_code order by b.region_code
  </code></pre>
  
  <p>I think it should be pretty straightforward, but am getting this:</p>
  
  <pre><code>FAILED: SemanticException [Error 10004]: Line 6:32 Invalid table alias or column reference 'b': (possible column names are: _col0, _col1)
  </code></pre>
  
  <p>Here is the YYY table:</p>
  
  <pre><code>hive&gt; desc YYY;
  OK
  status_code     int
  uid    string
  zip_code        string
  keyword string
  region_code     bigint
  dt      timestamp
  channel int
  </code></pre>
  
  <p>and XXX table:</p>
  
  <pre><code>hive&gt; desc XXX;
  OK
  group_key     string
  category    string
  uid    string
  dt      timestamp
  </code></pre>