I have been googling and I don't understand how to show the sum of a column and show the values of the columns that I add.
for instance:
Users table id, name, value1 value2
I would like to show the sum of the values 1 but I would like it to show me which values have been added.
following the example
1,pedro,2,2
2,pablo,4,2
3,pedro,3,2
I know that getting the sum is done by doing a SELECT id, name, SUM(value1) as sumvalue1
but this demands a single ROW with the sum and a single name
I would like it to show me something like this:
1,pedro,2,2
3,pedro,3,2
sumavalor1=5
Cheers! I hope you understand what I say.
PS: I want to show the payment history of a person and the total payments and that the client can see the date and the payment that he made before the sum of those payments. PS: In the same table there is more than 1 person with different names.
block quote
ok friend I realize through your tag that you are working apart from mysql as a database engine php as a language and javascript so this can facilitate something with what you say
first of all sometimes we want to do everything in a super complicated and unsustainable query so if what you want to do is a select with all the purchase history of a client then do it separately
you can then store that in an arraylist or draw it all at once in html now for the total do another query
in this way it is easy to read and maintain you can also do only the first query and the sum by php,
PS: if you had to filter the information, do a select before and store it in some variables in php, remember that you are using a set of tools that can make your life easier, don't kill yourself just using sql Salufos