When I insert product in ProductTable then parameter = 0 after seller it’s I’m insert parameter = 1. I define DateSeller by DatePlanNext. My ProductTable with data in below:
ProductTable here:
Id
|
DateSaller
|
Name
|
DatePlanNext
|
Parameter
|
1
|
09.09.2015
|
Melon
|
0
|
2
|
09.10.2016
|
Potato
|
|
0
|
3
|
10.10.2016
|
Tomato
|
|
0
|
4
|
09.09.2017
|
Cucumber
|
|
0
|
5
|
12.11.2017
|
Onion
|
0
|
6
|
07.02.2016
|
Cherry
|
|
0
|
7
|
|
Melon
|
09.09.2017
|
1
|
8
|
|
Tomato
|
10.10.2017
|
1
|
9
|
|
Onion
|
12.11.2017
|
1
|
ResultTable in below:
Id
|
PREDATE
|
PREPRODUCT
|
DateSaller
|
Name
|
DatePlanNext
|
NextProduct
|
1
|
09.09.2015
|
Melon
|
|
|
09.09.2017
|
Melon
|
2
|
09.10.2016
|
Potato
|
|
|
|
|
3
|
10.10.2016
|
Tomato
|
10.10.2017
|
Tomato
|
4
|
|
|
09.09.2017
|
Cucumber
|
|
|
5
|
|
|
12.11.2017
|
Onion
|
12.11.2017
|
Onion
|
6
|
07.02.2016
|
Cherry
|
|
|
|
|
My correct ResultTable in below:
Id
|
PREDATE
|
PREPRODUCT
|
DateSaller
|
Name
|
DatePlanNext
|
NextProduct
|
1
|
09.09.2015
|
Melon
|
|
|
09.09.2017
|
Melon
|
2
|
09.10.2016
|
Potato
|
|
|
|
|
3
|
|
|
09.09.2017
|
Cucumber
|
4
|
10.10.2016
|
Tomato
|
|
|
10.10.2017
|
Tomato
|
5
|
|
|
12.11.2017
|
Onion
|
12.11.2017
|
Onion
|
6
|
07.02.2016
|
Cherry
|
|