I have the following information in a MySQL table, what I need is to calculate the total by adding the result of multiplying the quantity by the corresponding price.
If it Precio con descuento
is different from NULL
it will be used to make the calculation.
| Cantidad | Precio | Precio con descuento |
|------------|--------|----------------------|
| 1 | 10 | NULL |
| 2 | 10 | 5 |
| 10 | 2 | 1 |
1 * 10 = 10
2 * 5 = 10
10 * 1 = 10
TOTAL: 30
Currently I have:
SELECT cantidad, precio, precio_descuento FROM ventas WHERE cerrado = 1;