Search code examples
javamysqlmathsummultiplication

I want to make math operations with data from an MySQL table (JAVA)


This is my question. The follwing is my current Table in MySQL.

TABLE

I have 2 INT columns precio (price) and cant (quantity) and I want to multiply these two tables. Example:
10 * 8 = 80
10 * 6 = 60
and so on, then I want to make a sum with all the results of the operations and print the total.

Does anyone know which MySQL commands I can use? Any help would be greatly apreciated.


Solution

  • Your Query would be like below : SELECT SUM( precio * cant ) as total FROM TABLE_NAME WHERE 1 = 1;