To access the previous row in sql LAG function
To access the previous row in sql LAG function , subract from previous row or add or multiply or divide
example :
select *,sal,
sal - coalesce(lag(sal) over (order by EMPNO), 0) as diff
from emp;
sal - coalesce(lag(sal) over (order by EMPNO), 0) as diff
from emp;
Comments
Post a Comment