Hi, folks. Need some help to develop a method/function. No problem if there is no code but I would like to start discussing the best way of doing this even in high level language. First of all would like to provide you with some information. The set that I use here is very small, but the data is on a table in mysql and there will be over a million rows. Its important because if I make a complex loop code, maybe there will be a lot of selects in there. The problem:
I have a set of numbers, all in a table called res_sup (code,value,date,type):
ROW1 = N1 | 100 | 06/16/2011 | R
ROW2 = N1 | 150 | 06/15/2011 | R
ROW3 = N1 | 170 | 06/14/2011 | R
ROW4 = N1 | 200 | 06/13/2011 | R
and so on...
The result that I need: save in a table called res_sup_per (code,date1,date2,value1,value2,perc,type) the following results:
ROW1 = N1 | 06/16/2011 | 06/15/2011 | 100 | 150 | 50% | R
ROW2 = N1 | 06/16/2011 | 06/14/2011 | 100 | 170 | 70% | R
ROW3 = N1 | 06/16/2011 | 06/13/2011 | 100 | 200 | 100% | R
ROW4 = N1 | 06/15/2011 | 06/14/2011 | 150 | 170 | 13% | R
ROW5 = N1 | 06/15/2011 | 06/13/2011 | 150 | 200 | 33% | R
ROW6 = N1 | 06/14/2011 | 06/13/2011 | 170 | 200 | 18% | R
feel free to coment and give your ideas. tks