Reputation: 23
I am trying to create a SELECT
statement to obtain the sum of all payments due from a table that contains payment schedule. Fields include PaymentID
, PaymentAmount
, NumberofMonths
. So for example, there are three rows:
PaymentId | PaymentAmount | NumberofMonths
==========================================
1 | 500 | 12
2 | 2000 | 8
3 | 1000 | 6
The total amount of all payments due would be $28,000.00. I'm a bit of a SQL/Oracle novice so I'm not sure how to get started with this.
Upvotes: 2
Views: 156
Reputation: 247820
You can use the aggregate function SUM()
and multiply the PaymentAmount
by the NumberOfMonths
:
select sum(PaymentAmount * NumberofMonths) Total
from yourtable
Upvotes: 2