title: Error while compiling statement: FAILED: SemanticException [Error 10002]
body: <pre><code>select d.order_type from migu_td_aaa_order_log_d d where  exists(select 1 
  from migu_user r where r.user_id = '156210106' and r.user_num = 
  d.serv_number) and d.product_id in ('2028594290','2028596512','2028597138' ) 
  order by d.opr_time desc limit 1 
  </code></pre>
  
  <p>why the above sql failed ,indicates :
      <b>FAILED: SemanticException [Error 10002]: Line 4:11 Invalid column reference 'opr_time' </b></p>
  
  <p>but the below one works :</p>
  
  <pre><code>select temp.order_type from (
  select d.* from migu_td_aaa_order_log_d d where  exists(select 1 from 
  migu_user r where r.user_id = '156210106' and r.user_num = d.serv_number) 
  and d.product_id in ('2028594290','2028596512','2028597138' ) order by 
  d.opr_time desc limit 1) temp;
  </code></pre>
  
  <p>this one works fine ,too ,and much more efficient than the second one:</p>
  
  <pre><code>select d.* from migu_td_aaa_order_log_d d where  exists(select 1 from 
  migu_user r where r.user_id = '156210106' and r.user_num = d.serv_number) 
  and d.product_id in ('2028594290','2028596512','2028597138' ) 
  order by d.opr_time desc limit 1
  </code></pre>
  
  <p>I only need to get order_type field,so even though the second one works,but it cost much more time.
  Can anyone help me?
  <b>Thanks a lot!</b></p>