Arithmetic operators include: addition (+), subtraction (-), multiplication (*), division (/), inversion (-), and modulus (MOD). These operators can be used on numeric columns.
In the example mentioned in the "Query data from multiple tables" topic, the example queries the quantity and price of each product purchased by the customer. The total amount paid for each type of products is calculated by multiplying the price by the quantity purchased. Therefore, you can add a column where values are equal to t3.ol_quantity * t4.i_price item_sum_price.
SELECT t1.c_first, t1.c_last, t1.c_credit, t2.o_ol_cnt, t2.o_entry_d, t3.ol_number, t3.ol_quantity, t4.i_name, t4.i_price, t3.ol_quantity * t4.i_price item_sum_price
FROM cust t1
JOIN ordr t2 ON (t1.c_id=t2.o_id AND t1.c_w_id=t2.o_w_id AND t1.c_d_id=t2.o_d_id)
JOIN ordl t3 ON (t2.o_id=t3.ol_o_id AND t2.o_w_id=t3.ol_w_id AND t2.o_d_id=t3.ol_d_id)
JOIN item t4 ON (t4.i_id=t3.ol_i_id )
WHERE t1.c_w_id=2 AND t1.c_d_id=5 and t1.c_last LIKE 'CALLY%'
ORDER BY t1.c_id, t2.o_id, t3.ol_number
;
Result:
+------------------+----------------+----------+----------+------------+-----------+-------------+--------------------------+---------+----------------+
| c_first | c_last | c_credit | o_ol_cnt | o_entry_d | ol_number | ol_quantity | i_name | i_price | item_sum_price |
+------------------+----------------+----------+----------+------------+-----------+-------------+--------------------------+---------+----------------+
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 1 | 5 | FJT8fkxaUh2aUbI | 79.95 | 399.75 |
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 2 | 5 | kiMk43vd9HidvmwG8x | 58.59 | 292.95 |
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 3 | 5 | JnJEOLUCjunrKkt4Z1pL | 85.26 | 426.30 |
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 4 | 5 | CrFVAZW3OhyekdDNc2rPH | 22.30 | 111.50 |
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 5 | 5 | fJpsyG11EjWIceJWaB | 41.39 | 206.95 |
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 6 | 5 | shseF8WI1VSPbWfswSsIuNC | 30.04 | 150.20 |
| wPS9EgAgztLRvSuZ | CALLYABLEOUGHT | GC | 7 | 2020-02-15 | 7 | 5 | prjdpUDOxRvAn5WiMVoT85B1 | 18.55 | 92.75 |
+------------------+----------------+----------+----------+------------+-----------+-------------+--------------------------+---------+----------------+
7 rows in set (0.01 sec)