0

I have a database table called expenses. They are multiple columns such as food, gas, fuel etc all with numeric values. How can I generate the value of all the records added together and then to show the total in a label?

Thanks for any help!

1 Answers1

0

I think you mean letting the database perform the sum for you. If that's the case then a query like this should do:

SELECT Food + Gas + Fuel AS Costs FROM Expenses

Should you want the total cost for all records? Then use SUM:

SELECT SUM(Food + Gas + Fuel) AS TotalCosts FROM Expenses
yazanpro
  • 4,512
  • 6
  • 44
  • 66