I have a table as such:
ID cost
1 654.77
2 953.54
3 345.98
...
for each of these ID's I have in a child table a list of percentages that equal 100 for each ID: (the percent has 4 dec places but here putting 2 for symplicity.
ID percent
1 .50
1 .50
2 .33
2 .33
2 .34
3 .24
3 .76
etc.
I have a sp that calculates an amount for each id for each percent. Here is a part of it. This caluclates this for each id.
(@jetempalloc has a record for each ID with fields:ID, cost, percent, damt
)
update @jetempalloc
set dacct=rtrim(fund)+ ' ' +drcode,
damt = (apercent * cost)
The problem is that the results in damt do not add up to the cost. There is often a discrepancy of a few cents, due to rounding. I have to go back and create a query to add a few cents to one of the damt's for each ID so that the sum for each ID will add up to the cost.
Any ideas for this query. Is there a better way to do this in the initial sp that I show above?
Thanks
smhaig (sql server 2000)
ID cost
1 654.77
2 953.54
3 345.98
...
for each of these ID's I have in a child table a list of percentages that equal 100 for each ID: (the percent has 4 dec places but here putting 2 for symplicity.
ID percent
1 .50
1 .50
2 .33
2 .33
2 .34
3 .24
3 .76
etc.
I have a sp that calculates an amount for each id for each percent. Here is a part of it. This caluclates this for each id.
(@jetempalloc has a record for each ID with fields:ID, cost, percent, damt
)
update @jetempalloc
set dacct=rtrim(fund)+ ' ' +drcode,
damt = (apercent * cost)
The problem is that the results in damt do not add up to the cost. There is often a discrepancy of a few cents, due to rounding. I have to go back and create a query to add a few cents to one of the damt's for each ID so that the sum for each ID will add up to the cost.
Any ideas for this query. Is there a better way to do this in the initial sp that I show above?
Thanks
smhaig (sql server 2000)