Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calculate a running balance
Message
De
17/09/2007 12:13:25
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
01254611
Message ID:
01254810
Vues:
18
Thanks Sergey. I know how to do this with a cursor I just try and avoid them when I can. I may do this with VFP also since the result set will not be that much different in size either way.

Thanks again for your help.

>I missed that subsequent % is applied to leftover amount not to the total. It should be straitforward to do with a cursor. I'll take a look if it can be done with a query, when I have time.
>
>>No that is not it. Think of the commission as a bucket of water. Each individual has a right to a certain percentage of what remains in the bucket of water. So George dips out 5% of the water. Next, Henry gets to dip out 15% of what is left in the bucket. And so it goes until the bucket is empty. I need to do the same with this matrix. I need to know what remains of the unallocated commission on every row until the entire amount is allocated.
>>
>>Thanks.
>>
>>
>>
>>>Are you saying that total commissions % could be bigger than 100%?
>>>
>>>>Total commission paid is 3000.00. The first line pays 5% of 3000.00 for 150.00. The second line pays 15% of the remainder of 3000.00-150.00 or 2850. If I calculate this as a set, I have to know the balance remaining for each line. Maybe this is not possible to do without a cursor.
>>>>
>>>>Thanks.
>>>>
>>>>>Hi James,
>>>>>
>>>>>I'm not sur why do you need running balance. Can you clarify?
>>>>>
>>>>>>
>>>>>>I am using Sybase SQLAnywhere database. This database uses T-SQL but probable more compatible with the 2000 version.
>>>>>>
>>>>>>I am working a a commission matrix that I need to calculate. The matrix consist of a number of rows that pay different recipients for their portion of the total commission for a sale. I need a way to calculate a remainder of commission for each row until all the commission has been allocated. For example:
>>>>>>
>>>>>>
>>>>>>Total commission 3000.00
>>>>>>Recipient		Rate				Amount		Balance
>>>>>>Starting Balance							3000
>>>>>>George			5%				150.00	        2850
>>>>>>Henry			15%				427.50	        2422.50
>>>>>>Jack			70%				1695.75	        726.75
>>>>>>Me 			Remainder	    	        726.75	        0
>>>>>>
>>>>>>
>>>>>>I know how to do this in VFP but I hope to be able to do this using a stored procedure.
>>>>>>
>>>>>>Thanks.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform