Add all the fields of several records corresponding to a MySQL column

1

How can I add all the fields that correspond to a column in a table?

Example:

| ID  | Cantidad |
------------------
| 1   | 200      |
| 2   | 150      |
| 3   | 60       |

How can I add up all the "Quantity" fields? That is, (200 + 150 + 60).

You can start directly with the search. Ta I have the connection made.

Thank you very much!

    
asked by ByBrayanYT - Tops y más 31.10.2018 в 17:19
source

1 answer

0

(MYSQL) Your SQL should look like this:

Select sum(cantidad) from _nombreTabla_;

That way you can add all the RECORDS OR ROWS (not "fields", they are not called "fields") of a table, as long as they are obviously numerical values.

Documentation and examples HERE

    
answered by 31.10.2018 / 20:58
source