MS SQL Server - stored procedure help

Associate
Joined
6 Jan 2006
Posts
1,024
Location
Midlands
I have a basic select statement i.e.

SELECT
ID, A, B, C
FROM
tblScores

I would like to also return the sum of A,B,C AS 'Total'

However A,B or C can be nulls

I assume i would have to check for nulls and then them together? How do i achieve this?
 
Thanks! Appreciate the help.

Had to take out the Sum keyword to get it to work.

SELECT
ID, (ISNULL(A, 0)) + (ISNULL(B, 0)) + (ISNULL(C, 0)) AS [Total]
FROM
tblScores
 
Back
Top Bottom