这个问题与my previous question的答案有关。请注意datetime
是字符串。因此我将其转换为unix时间戳。
我在Hive 1.2.1中执行此查询:
select count(*) / count(distinct to_date(datetime)) as trips_per_day
from (select radar_id,to_unix_timestamp(datetime),lead(radar_id) over w as
next_radar_id,lead(to_unix_timestamp(datetime)) over w as
next_datetime
from mytable
where radar_id in ('A21','B15') window w as
(partition by car_id order by to_unix_timestamp(datetime))) t
where radar_id = 'A21' and next_radar_id = 'B15'
and to_unix_timestamp(datetime) + 30*60 > to_unix_timestamp(next_datetime);
但是我收到以下错误:
SemanticException [错误10004]:行11:18无效的表别名或 列引用' datetime' :(可能的列名是:radar_id,_c1, next_radar_id,next_datetime)
哪里出错?