Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Monday, June 11, 2007 2:52 PM
I want to sum up the entries of all columns of the same row and put the result in its last column.
How does one accomplish this?
Example:
Col1 Col2 Col3 Result
Row1 1 2 3 6
Monday, June 11, 2007 2:57 PM ✅Answered
Try:
select col1, col2, col3, col1 + col2 + col3 as result
from dbo.t1
You can also add a calculated column to you table or create a view.
alter dbo.t1
add result as isnull(col1, 0) + isnull(col2, 0) + isnull(col3, 0)
go
select * from dbo.t1
AMB
Monday, June 11, 2007 3:28 PM
Thank you hunchback, this works for me.