'How to subtract two query result in hive
I have tried this code in SQL it is working fine but in hive it is not working
select((select sum(price) from apart where construction_year=2020) - (select sum(price) from apart where construction_year=1990)) as difference_between_1990_and_2020;
Solution 1:[1]
you need to convert them to subquery
select p20-p19 as difference_between_1990_and_2020
from
(select((select sum(price) p20 from apart where construction_year=2020) rs20
join (select sum(price) p19 from apart where construction_year=1990) rs19 on 1=1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Koushik Roy |