Ahoj, zatím mě napadlo jen takové provizorní řešení, ale možností je více.
declare @result int = 0
declare @condition int = 3
declare @myTable table(
id int,
a int,
b int,
c int,
d int,
e int,
f int,
g int,
h int,
i int
)
insert into @myTable values
(5, 2, 3, 2, 3, 6, 4, 7, 3, 2)
select
@result += case when a = @condition then a else 0 end,
@result += case when b = @condition then b else 0 end,
@result += case when c = @condition then c else 0 end,
@result += case when d = @condition then d else 0 end,
@result += case when e = @condition then e else 0 end,
@result += case when f = @condition then f else 0 end,
@result += case when g = @condition then g else 0 end,
@result += case when h = @condition then h else 0 end,
@result += case when i = @condition then i else 0 end
from @myTable where id = 5
select @result