Skip to content
Advertisement

How to SUM two fields within an SQL query

I need to get the total of two fields which are within the same row and input that number in a field at the end of that same row.

This is my code.

Is this what the SUM function is used for, or can you only use the SUM function for getting the total of a column?

Thanks

Advertisement

Answer

SUM is an aggregate function. It will calculate the total for each group. + is used for calculating two or more columns in a row.

Consider this example,

 

will result

 

will result

 

will result

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement