How to SUM two fields within an SQL query

前端 未结 8 1983
南笙
南笙 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:51

    Try the following:

    SELECT *, (FieldA + FieldB) AS Sum
    FROM Table
    
    0 讨论(0)
  • 2020-11-28 22:51

    If you want to add two columns together, all you have to do is add them. Then you will get the sum of those two columns for each row returned by the query.

    What your code is doing is adding the two columns together and then getting a sum of the sums. That will work, but it might not be what you are attempting to accomplish.

    0 讨论(0)
提交回复
热议问题