我在SQL中尝试过这个代码,它工作正常,但在hive中它不工作
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;
您需要将它们转换为子查询
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