pivot - SQL Calculations for budgeting -


i have database contains following columns: vendor, amount, startdate, months

i able calculate average monthly amount based on months entered. see calculate out start date end date based on startdate + months calculation. resulting table this:

vendor1 has 2 months of 1112 starting jan 1 while vendor2 has 3 months of 2040 staring feb 1

|       | annual | jan   |  feb  |  mar  | apr   |  vendor1 |  2,224 | 1,112 | 1,112 |       |       | vendor2 |  6,120 |       | 2,040 | 2,040 | 2,040 |  

any assistance or direction appreciated.

that's strange db design. however, here's you've got try:

select (amount * months) annual, (case @(startdate < date("01.02.year")) when 1 amount else null) jan table --etc months 

will think of modifications though, because way little straightforward.


Comments