• Thank you for your answer...

    But my issue is not resolved

    Because of this sort must be based on the Id field

    I used the following method

    SET @SQLStr ='DECLARE @F3 bigint=0

    update viwe1 set @f3=f3=@f3+ (f1-f2),

    f5 = case when @f3<0 then ''c''

    when @f3>0 then "b" when @f3=0 then "a" end '+

    @where

    EXEC(@SQLStr);

    But sometimes makes mistakes

    It is right on the main table

    But the mistaken view