I have the following problem, I have 1 table in mysql where I have the information of people who have a debt from a clothing store for several years, what I want is a query that gives me the name of the person and that their debt is added.
Example of the table and its data:
nombre | año | monto
Pepe | 2011 | 100.00
Pepe | 2012 | 300.00
Pepe | 2016 | 900.00
Maria | 2011 | 100.00
Maria | 2012 | 530.00
Result:
Pepe | 2011 | 13000.00
Maria | 2012 | 630.00
The year doesn't matter, I just want the sum.
You can do it with the
SUM
. Consider that itSUM
is a grouping function, so a statement is neededGROUP BY
that indicates the fields that will be grouped to perform the sum.Here is the example of what it would look like.