Using LAG function

Show value from current row and the previous row.

Last updated:

Warning: Review and test in a non-production environment before running.

Back to results

select MISPAR_TZ,shana,hodesh,HAFKADOT_OVED,
          LAG(HAFKADOT_OVED,1,0) over (order by shana,hodesh) as prev
  from table
where mispar_tz=111111111
   and shana in(2013,2014)
order by shana,hodesh;