Hi @stasv85
because the lead/lag function dont work
The reason is that you set lead offset = 0.
Basic Syntax :
LAG (scalar_expression [,offset] [,default]) OVER ( [ partition_by_clause ] order_by_clause )
Have a change like this : lag ( sum (salary),1,0) OVER ( ORDER BY sum (salary)) as PrevOrder
For more details about LAG , please refer to this document: LAG (Transact-SQL)
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.