Advertisement
lukifrancuz

BD3_K1_Z4_g1

Nov 17th, 2022
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.36 KB | None | 0 0
  1. --4
  2. declare @i int = 10000
  3. declare @sum int = 0
  4.  
  5. while @i < 100000
  6. begin
  7.     declare @number varchar(5) = cast(@i as varchar)
  8.     declare @tempSum int = 0
  9.     declare @j int =1
  10.    
  11.     while (@j <= 5)
  12.     begin
  13.         set @tempSum = @tempSum + SUBSTRING(@number, @j, 1)
  14.         set @j=@j+1
  15.     end
  16.  
  17.     if @tempSum = 12
  18.         set @sum = @sum + @i       
  19.  
  20.     set @i = @i + 1
  21. end
  22.  
  23. select @sum
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement