我有一个表,其中的行由hdfs组成。我想计算表中每个id的平均日期差。这是我正在使用的查询,但它一直给我error:-
select id, AVG(new_visit) over x+1 as avg_lag_btwn_visit
from (select id, date_visit, datediff(date_visit,LAG(date_visit)) over w > 1 as new_visit
from (select id, date_visit from table) a
window w as (partition by id order by date_visit)
) b
window x as (partition by id order by date_visit);
编辑:样本输入:12345,2018-01-01 12345,2018-01-12 23456,2018-02-01 12345,2018-01-20 23456,2018-02-20 34567,2018-03-01样本输出:12345,9.5 23456,19 34567,0
编译语句时出错:失败:semanticexception无法将窗口调用拆分为组。至少有一个组只能依赖于输入列。还要检查循环依赖关系。基本错误:函数datediff无效
暂无答案!
目前还没有任何答案,快来回答吧!