How to SUM two fields within an SQL query

前端 未结 8 2041
南笙
南笙 2020-11-28 21:58

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.

S         


        
8条回答
  •  旧巷少年郎
    2020-11-28 22:35

    The sum function only gets the total of a column. In order to sum two values from different columns, convert the values to int and add them up using the +-Operator

    Select (convert(int, col1)+convert(int, col2)) as summed from tbl1
    

    Hope that helps.

提交回复
热议问题