I have a table that has "periods" and looks like this (added some rows as example):
| StartDate | EndDate | Amount1 | Amount2 | Type ============================================================== 1 | 20110101 | 20110131 | 89 | 2259 | 1 2 | 20110201 | 20110228 | 103 | 50202 | 1 3 | 20110301 | 20110331 | 90 | 98044 | 1 4 | 20110401 | 20110430 | 78 | 352392 | 1 ==============================================================
As you can see each "period" is exactly one month. Each month is represented four times (there are 4 types) so this table has 48 rows.
I have a selection that gives me the number of days per period (simply, the day out of the EndDate, since its always the amount of days in that period) and Amount1PerDay and Amount2PerDay (the amount of that period divided by the number of days).
The first problem is:
I need a View
on this table that shows me one row for each day in every period with the Amount1 and Amount2 columns that hold the value of that period divided by the number of days in that period.
The second problem is:
Most of these divisions do not give me a whole number. Decimals are not an option, so I need to divide the remaining days (after division) among the first days of that period.
Take January as an example: Amount1 has 89. Divided over 31 days thats almost 2,9. So its 2 per day, and the first 27 days get 3 (,9 * 31 = 27). That way the result has only whole numbers in it.