E
E
esy19932015-07-04 19:59:40
SQL
esy1993, 2015-07-04 19:59:40

How to sum field values ​​by unique ID in SQL query?

549d4f38810746e4ac1eb33569b0c9f5.png
There is a table with the amounts of payments on the debts of counterparties. It is necessary to formulate a query that will sum the values ​​of the amount_of_payment field for each unique id_debt and, as a result, return the total amount of payments for each debt separately. That is, the resulting table should look like this:
1786029cf75946bf957cefba713aace0.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2015-07-04
@esy1993

select id_debt, sum(amount) from tablename where /**/ group by id_debt;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question