I have a similar question about adding several columns to another column, but mine are decimals instead. But I would like to do just a query inside of the database itself. Is it possible?
Here is my scenario:
UPDATE operating_expenses
SET Total = Fuel+Oil_Change+Tire_Repairs+Parts+Insurance+License_Fees+Toll+Misc
WHERE OE_ID = OE_ID
It adds up but the Total column comes up with a different result lower than the real total.
Thanks for you very speedy repply. But that did not work, but I had played around with other elements as you see below and it worked, BUT???
Now the problem is that I have to send the UPDATE form twice before it actually makes the changes into the database. Do you know why???
this was your code—
SELECT Fuel
, Oil_Change
, Tire_Repairs
, Parts
, Insurance
, License_Fees
, Toll
, Misc
, Fuel + Oil_Change + Tire_Repairs + Parts +
Insurance + License_Fees + Toll + Misc AS Total
FROM operating_expenses
this code works
SELECT OE_ID, Date_, Trip_No, Fuel, Oil_Change, Tire_Repairs, Parts, Insurance, License, Toll, Misc,
SUM(Fuel+Oil_Change+Tire_Repairs+Parts+Insurance+License+Toll+Misc) AS Total
FROM operating_expenses
WHERE OE_ID = colname