sql转换为hql

时间:2016-11-30 09:41:29

标签: sql hadoop hive

我有一个像这样的SQL:

SELECT s_store_name ,
   sum(ss_net_profit)
FROM store_sales ,
     date_dim ,
     store,
  (SELECT ca_zip
   FROM
 ( SELECT substr(ca_zip,1,5) ca_zip
  FROM customer_address
  WHERE substr(ca_zip,1,5) IN ( '27385',  '79307', '15492') INTERSECT
    SELECT ca_zip
    FROM
      (SELECT substr(ca_zip,1,5) ca_zip,
              count(*) cnt
       FROM customer_address,
            customer
       WHERE ca_address_sk = c_current_addr_sk
         AND c_preferred_cust_flag='Y'
       GROUP BY ca_zip
       HAVING count(*) > 10)A1)A2) V1
WHERE ss_store_sk = s_store_sk
  AND ss_sold_date_sk = d_date_sk
  AND d_qoy = 1
  AND d_year = 2002
  AND (substr(s_zip,1,2) = substr(V1.ca_zip,1,2))
GROUP BY s_store_name
ORDER BY s_store_name LIMIT 100;

现在,我想将其转换为hql,但是hive不支持INTERSECT,我该怎么办?此外,hive似乎也不支持as

0 个答案:

没有答案