Hi,@messer gatti
Welcome to Microsoft T-SQL Q&A Forum!
Please check this:
update [SampleRetail].[sale].[Analiz]
set hesap_kitap =
case when s_quantity > (LAG(s_quantity) OVER (ORDER BY product_id ASC, discount ASC))
Then 'pozitif'
when s_quantity < (LAG(s_quantity) OVER (ORDER BY product_id ASC, discount ASC))
Then 'Negative'
else 'Neutral'
end
Note: Since you did not provide the test data, I can only write the test code according to your description. If the test result is wrong, please put the test code and table building statement in the comments, and we will continue to test for you.
Best regards,
Bert Zhou
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.