Hive 无法在配置单元表中使用CTE写入查询

Hive 无法在配置单元表中使用CTE写入查询,hive,hiveql,common-table-expression,Hive,Hiveql,Common Table Expression,编写一个查询,查找10月至11月因购买而产生的收入变化。 我得到的错误是: 失败:缺少解析异常行2:0(位于“选择”附近的“,”中 语句行3:0中的“,”附近“,”处缺少语句行2:117) 无法识别语句中“SELECT”“SUM”()附近的输入 请帮助我了解我哪里做错了一个CTE是一个查询。可以在一个语句中计算两个月,如下所示: WITH month_revenue AS (SELECT SUM(price) AS Oct_Revenue FROM attribute_partit

编写一个查询,查找10月至11月因购买而产生的收入变化。 我得到的错误是:

失败:缺少解析异常行2:0(位于“选择”附近的“,”中 语句行3:0中的“,”附近“,”处缺少语句行2:117) 无法识别语句中“SELECT”“SUM”()附近的输入


请帮助我了解我哪里做错了

一个CTE是一个查询。可以在一个语句中计算两个月,如下所示:

   WITH month_revenue AS 
   (SELECT SUM(price) AS Oct_Revenue FROM attribute_partition WHERE event_type= 'purchase' AND 
   MONTH(event_time) = '10')  , 
   (SELECT SUM(price) AS Nov_Revenue FROM attribute_partition WHERE event_type= 'purchase' AND 
   MONTH(event_time) = '11')
   SELECT (Oct_Revenue - Nov_Revenue) FROM month_revenue ;
 WITH month_revenue AS 
   (SELECT 
         SUM(case when MONTH(event_time) = '10' then price else 0 end) AS Oct_Revenue,
         SUM(case when MONTH(event_time) = '11' then price else 0 end) AS Nov_Revenue
    FROM attribute_partition 
    WHERE event_type= 'purchase' 
      AND MONTH(event_time) in ('10', '11')
  )  

   SELECT (Oct_Revenue - Nov_Revenue) FROM month_revenue ;