clay.calvin,
The SUM() function is another option that may be applicable. Compare the MAX() function to the SUM() function (note I have changed the VALUES in the fourth insert to demonstrate the difference):
DECLARE @MyTable AS TABLE
(
Column1 INT,
Column2 INT,
Column3 INT,
column4 INT
);
INSERT @MyTable VALUES (0,6,0,0);
INSERT @MyTable VALUES (0,0,30,0);
INSERT @MyTable VALUES (4,0,0,0);
INSERT @MyTable VALUES (1,2,3,18);
SELECT Col1 = MAX(Column1), Col2 = MAX(Column2), Col3 = MAX(Column3), Col4 = MAX(Column4)
FROM @MyTable
SELECT Col1 = SUM(Column1), Col2 = SUM(Column2), Col3 = SUM(Column3), Col4 = SUM(Column4)
FROM @MyTable
output from first statement:
Col1 Col2 Col3 Col4
----------- ----------- ----------- -----------
4 6 30 18
output from second statement:
Col1 Col2 Col3 Col4
----------- ----------- ----------- -----------
5 8 33 18
The aggregate function you will choose depends on what you want to accomplish.
-gjr