DECLARE @FATID INT = (SELECT MIN(FATID)-1 FROM FATURA WHERE KYTARIH>(CONVERT(VARCHAR,YEAR(DATEADD(MONTH,-2,GETDATE()))) + '-' + RIGHT('0'+CONVERT(VARCHAR,MONTH(DATEADD(MONTH,-2,GETDATE()))),2) + '-01'))
update FATURA
   set FISTURID = case 

                    when TURADI 
                      in ( 'ALĨ', 'ALIS' ) 
                    then  Cast( 51 as int ) 
                    
                    when TURADI 
                      in ( 'SATĨ ƯADE', 'SATIS IADE' ) 
                    then Cast( 54  as int )  
                           
                    when TURADI 
                      in ( 'ALĨ ƯADE', 'ALIS IADE' ) 
                    then Cast( 53 as int )
                    
                    when TURADI 
                      in ( 'PERAKENDE' ) 
                    then Cast( 69 as int ) 
                                  
                    else Cast( 52 as int )
                     
                  end

 where FISTURID is null AND FATID>@FATID
 
 
