Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Server 2008 information per month divided onto days
    primarykey
    data
    text
    <p>I have a table that has "periods" and looks like this (added some rows as example): <br></p> <pre> | 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 ============================================================== </pre> <p><br> 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.<br> <br> 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).<br> <br> The first problem is:<br> I need a <code>View</code> 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.<br> <br> The second problem is:<br> 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.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload