如何在hive中减去两个查询结果



我在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

相关内容

  • 没有找到相关文章

最新更新