title: Cross Join in Hive
body: <p>I'm trying to create a new column <code>time_period</code> while running the query below. If the date difference between a given transaction and the most recent transaction in the reference table is fewer than 7 days, then mark it as a <code>recent</code> transaction, else mark it as an <code>old</code> transaction.</p>
  <p>However, the query below is generating an error in the subquery associated with the cross join. The error is &quot;Cannot recognize input near 'select' '(''max'</p>
  <pre><code>SELECT
      c.*
      FROM(
          SELECT
           a.acct_nb,
           a.txn_date,
           a.txn_amt,
           (CASE WHEN datediff(b.most_recent_txn,a.txn_date)&lt;7 THEN 'recent' ELSE 'old' END) AS time_period
           FROM db.t1 a
           CROSS JOIN(
                SELECT max(txn_date) AS most_recent_txn --ERROR OCCURS HERE
                FROM db.t1 b)
          )c
          WHERE c.time_period='new';
  </code></pre>
  <p>What could be causing this error?</p>