SQL to Hive查询语法

时间:2015-05-26 10:18:06

标签: hive

如何将以下SQL转为Hive查询?我收到错误FAILED: ParseException line 2:31 cannot recognize input near 'select' 't2' '.' in expression specification

select ip,
       sum(case when score <> (select t2.score from score t2
                               where t2.timestamp = (select max(timestamp) from score
                                                     where ip = t2.ip
                                                       and timestamp < t1.timestamp)
                                 and t1.ip = t2.ip) then 1 else 0 end)
from score t1
group by ip;

1 个答案:

答案 0 :(得分:0)

Hive不支持case语句AFAIK中的子查询。您可以从内联视图将其重构为外部查询(使用大小写)。

select ip, sum(case when score <> s.score) ..
from (select  t2.score ..) s