Skip to content
Advertisement

How to SUM two SUMmed SQL result fields

I have a simple table structure holding records of reagent_bottles and reagent_aliquots.

Aliquots are created from bottles, and an aliquot record got a foreign key, bottle_id, to a bottles id.

To get the total volume of a particular reagent (counting both the volume in the bottles and the volume in the aliquots), the following query does the job, partly:

returns for the above reagent id (408):

Adding bVolume and aVolume, is the correct answer, i.e. 8.

Question is, how do I re-write the above query to create a new field, total_volume, summing bVolume and aVolume within the query?

I tried this:

but getting the error, Unknown column, bVolume in field list..!

Advertisement

Answer

Sum the original columns:

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