Query Help

Query Help

am 30.01.2005 03:54:05 von How Loon

Greetings,


Question
========
How to I create a SQL query to handle my Case A and
Case B, or may be 2 difference queries?

Thanks in advance.



Legends
=======
1) Total, Interest_Rate, Interest, Capital,
Installment_Amount and Installment_Month are the
fields in table 'money' with speficied values.

2) @Interest, @Capital, @Installment_Amount and
@Installment_Month are variables used in SQL query for
calculation, and the value (result) for each field
also would be stored in respective field.


Case A - By Installment Amount
==============================
Total = $12000
Interest_Rate = 7%
Installment_Amount = $1050


@Interest = Total x Interest_Rate
$840 = $12000 x 7%

@Capital = Installment_Amount - @Interest
$210 = $1050 - $840

@Installment_Month = Total / @Capital
57.14 => 58 Months = $12000 / $210

******** RESULT SET *************
Installment_Month = 58 (Rounded)
Capital = 210
Interest = 840
********************************



Case B - By Installment Months
==============================
Total = $12000
Interest_Rate = 7%
Installment_Month = 17 Months


@Interest = Total x Interest_Rate
$840 = $12000 x 7%

@Capital = Total / Installment_Month
$705.88 => $706 = $12000 / 17

@Installment_Amount = @Interest + @Capital
$1546 = $840 + $706

******** RESULT SET *************
Installment_Amount = 1546
Capital = 706 (Rounded)
Interest = 840
*********************************


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

--
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe: http://lists.mysql.com/win32?unsub=gcdmw-win32@m.gmane.org