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;

Comments

Popular posts from this blog

opaque schema xsd (standard file used in OIC)

DOCUMENTATION ON SANDBOX and PERSONALIZATION

SQL,PLSQL interview practice and DSA patterns