I have a table which holds values from both October and November months. So basically I have to find the change in revenue generated under event_type 'purchase' from Oct to Nov. I tried this query but it is throwing errors (code is base on Hive Query Language HQL)
SELECT SUM(November) AS November, SUM(October) AS October, 'DIFFERENCE'=SUM(November)-SUM(October)
FROM
(
SELECT price AS October, 0 AS November FROM Shopping WHERE date_format(event_time,'MM')=10 AND event_type='purchase'
UNION ALL
SELECT 0 AS October, price AS November FROM Shopping WHERE date_format(event_type,'MM')=11 AND event_type='purchase'
) AS a;
Error:
FAILED: ParseException line 2:0 cannot recognize input near 'SELECT' 'price' 'AS' in join source
What's wrong with this code and how can I solve the query using HQL