I have made a table that contains for two years (24 months), for two product groups, the turnover per month (for each productgroup). I would like to use these turnovers to predict the future turnovers for both productgroups for the coming 12 months.
I am able to predict future turnovers for one productgroup, using the lag function. But how do I do that for two productgroups? Is that using the partition by clause, or by using the order by???
Please help. I am not at my work currently, tomorrow I can give my sql script (it's all in Oracle SQl, so no other options are available).
Once you got your database back, why wouldn't you try both PARTITION BY and ORDER BY and see which one will give the correct result? Or, even better, first read documentation about it so that you'd know what is 'partition by' used for, and what 'order by'.
Ok, for people who are really into helping, here's my syntax:
trunc(((0.4*lag(b.ROY_aantal_sec,1) over (partition by b.clusters order by a.periode,b.clusters)+0.6*lag(b.ROY_aantal_sec,2) over (partition by b.clusters order by a.periode,b.clusters))+
(0.05*lag(b.ROY_aantal_sec,12) over (partition by b.clusters order by a.periode,b.clusters)+0.95*lag(b.ROY_aantal_sec,24 ) over (partition by b.clusters order by a.periode,b.clusters)))/2) as voorspelling
from periode a
left outer join tst2 b
on (a.periode=b.periode and b.lob='IC')