user8545255
user8545255

Reputation: 839

SQL code for algebraic formula

Want to calculate N from the formula

How to solve 'N' for given EMI, P & R?

Also:

id  principal_amount   EMI   rate 
 1    10000           5000   10.5
 2    32000           8000   9.5
 3    33000           9000   7

Need to calculate 'N' from the formula and have it in a table.

Expected:

 id   principal_amount   EMI   rate   N 
 1    10000             5000   10.5   calculate from formula
 2    32000             8000   9.5    calculate from formula
 3    33000             9000   7      calculate from formula

Upvotes: 0

Views: 226

Answers (1)

diziaq
diziaq

Reputation: 7825

Just arithmetically solve the equation against N and use standard log function to get the algorithm:

select log(1 + rate, EMI / (EMI - principal_amount * rate )) AS N
  from my_table;

Upvotes: 2

Related Questions