Cany anyone suggest, how to use the Lead and lag function in Hive.
I am using Hive* 0.10 version*. Is there any way to make it work in 0.10
version.
I have used  the below code in Oracle,  But it is not working in Hive.
I need to compare the difference between the previous record and currect
record.

*Oracle code for LAG :-*

SELECT empno,
       ename,
       job,
       sal,
       LAG(sal, 1, 0) OVER (ORDER BY sal) AS sal_prev,
       sal - LAG(sal, 1, 0) OVER (ORDER BY sal) AS sal_diff
FROM   emp;


*Oracle code for LEAD :-*

SELECT empno,
       ename,
       job,
       sal,
       LEAD(sal, 1, 0) OVER (ORDER BY sal) AS sal_next,
       LEAD(sal, 1, 0) OVER (ORDER BY sal) - sal AS sal_diff
FROM   emp;



-- 
----------------------------------------------
Regards,
Prasad

Reply via email to