SQL cumulative percent formula

B

biz

Hello,

I am trying to get the correct SQLfunction/formula for calculating
cumulative percent. Please refer to "Cumulative % of (CPA)" column below.
For example:
Cumulative % of CPA (Row2) = (Principal Balance1+Principal Balance2)/CPA.
Cumulative % of CPA (Row3) = (Principal Balance1+Principal
Balance2+Principal Balance3)/CPA
etc....
(Please see visual example below):

(CPA): $300,000,000.00

Row Principal Balance Cumulative % of (CPA)
1 $10,000,000.00
2 $20,000,000.00 0.1000
3 $21,000,000.00 0.1700
4 $11,000,000.00 0.2067
5 $12,000,000.00 0.2467
 
K

Ken Snell \(MVP\)

Something like this, perhaps:

SELECT [Row], [Principal Balance],
(SELECT (Sum(T.[Principal Balance])/CPA) AS SumPB
FROM YourTableName AS T
WHERE T.[Row]<=YourTableName.[Row])
AS [Cumulative % of (CPA)]
FROM YourTableName;

From where is the query going to get the CPA value?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top