I would like to make next query:
select ...,
(
source.F1 - /* current row */
LAG(IIF(source /*current row*/.F2 = source /*lag row*/.F2, source.F1, 0), 12, source.F1)
OVER (...)
) as alias
from source
Desired result: when row selected by LAG function (number 12 in partition) match condition currentRow.F2 = rowSelectedByLag.F2 then return rowSelectedByLag.F1, otherwise 0.
Issue: how to reference current row in IIF condition?