문제

I need convert this sql to hive ql. I find the hive don't have operator in .

select type,sum(cost) as Cost from TableName 
WHERE trans_id in (SELECT trans_id FROM TableName WHERE type=0)
group by type;
도움이 되었습니까?

해결책

Write it as a LEFT SEMI JOIN:

select type,sum(cost) as Cost from T1
LEFT SEMI JOIN T2 ON T1.trans_id = T2.trans_id
WHERE type=0
group by type;

As with Hive 0.13 you won't have to do this as Hive 0.13 supports IN/EXISTS clause with subqueries (HIVE-784).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top