where子句中的配置单元子查询

im9ewurl  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(272)

我是新到Hive请帮助我,我有一个表名普拉克,我需要找到的产品,使更多的利润(价格成本)比产品鼠标。我尝试了下面的查询,但它不起作用。

select product_name,price-cost 
from   prac 
where  price-cost > (select price-cost from prac where product_name='mouse')

我的数据是

id,product_name,product_type,price,cost,date
100,maker,stationary,25,22,2008-01-15
101,mouse,computer,450,350,2009-04-16
102,white  board,stationary,450,375,2010-06-25
103,sony viao,computer,35000,42000,2010-09-21
wtlkbnrh

wtlkbnrh1#

我知道答案了

select a.*,a.price-a.cost profit
from prac a 
join (select price-cost p from prac where p_name='Maker') b 
where a.price-a.cost>b.p;

相关问题