sql - Apportioning data into new columns -
morning,
i quite new sql server 2008 wondering if me.
i have:
select c.code, d.date, d.date_previous, cast(d.date-date_previous int) days, d.units, d.cost table1 d inner join table2 p on d.id = p.id inner join table3 c on p.c_id = c.id date_previous > '31/12/2012'
this bringing 1 row per invoice received after 31/12/2012. aim following columns:
code jan data feb data mar data etc...
- one unique code per line (so i'm assuming row partitioning required)
- where bill has period of 3 months with, example, 300 units, i'd separated out across 3 months (100 in each)
i'm aware i'd need use pivot function , temp tables i'm not advanced yet.
Comments
Post a Comment