I need to implement the below logic
Posted: Thu Mar 03, 2011 12:55 am
Hi All,
I Need to implement below logic,Please help me out.I have the SOURCE and REFERENCE tables as below:
SOURCE
DATE Store Sku
1-Dec-10 A 1
2-Dec-10 B 1
3-Dec-10 C 1
3-Dec-10 B 2
3-Dec-10 B 1
REFERENCE
DATE Store Sku Price
1-Dec-10 A 1 10
3-Dec-10 A 1 7
5-Dec-10 A 1 10
1-Dec-10 A 2 12
1-Dec-10 B 1 5
3-Dec-10 B 1 6
1-Dec-10 B 2 8
1-Dec-10 C 1 15
For every record in the SOURCE I have to get the PRICE from Refrence.
If DATE,STORE,PRICE matches we need to retrieve the PRICE value from the Reference else
I need to decrement the DATE value till found the exact match for that particular DATE,STORE & SKU
For example:
For Ist Record in the SOURCE(1-Dec-10 A 1) we have exact match in the reference so will get the PRICE value(10)
For 2nd Record in the SOURCE(2-Dec-10 B 1) I don't have exact match in the Reference so I will decrement the DATE by 1 then 2-Dec-10 becomes 1-Dec-10.Now I have to look for 1-Dec-10 B 1 in the Reference,now I will find the exact match with PRICE 5.
For 3rd Record in the SOURCE(3-Dec-10 C 1) I don't have exact match in the Reference so I will decrement the DATE by 1 then 3-Dec-10 becomes 2-Dec-10.Now I will look for 2-Dec-10 C 1 in the Reference I don't find the exact match in the Reference.So again I need to decrement the DATE by 1 then 2-Dec-10 becomes 1-Dec-10.Now I will look for 1-Dec-10 C 1 combination match in the Reference,now I will find the exact match with PRICE 15.
Thanks & Regards,
Kalpana.
I Need to implement below logic,Please help me out.I have the SOURCE and REFERENCE tables as below:
SOURCE
DATE Store Sku
1-Dec-10 A 1
2-Dec-10 B 1
3-Dec-10 C 1
3-Dec-10 B 2
3-Dec-10 B 1
REFERENCE
DATE Store Sku Price
1-Dec-10 A 1 10
3-Dec-10 A 1 7
5-Dec-10 A 1 10
1-Dec-10 A 2 12
1-Dec-10 B 1 5
3-Dec-10 B 1 6
1-Dec-10 B 2 8
1-Dec-10 C 1 15
For every record in the SOURCE I have to get the PRICE from Refrence.
If DATE,STORE,PRICE matches we need to retrieve the PRICE value from the Reference else
I need to decrement the DATE value till found the exact match for that particular DATE,STORE & SKU
For example:
For Ist Record in the SOURCE(1-Dec-10 A 1) we have exact match in the reference so will get the PRICE value(10)
For 2nd Record in the SOURCE(2-Dec-10 B 1) I don't have exact match in the Reference so I will decrement the DATE by 1 then 2-Dec-10 becomes 1-Dec-10.Now I have to look for 1-Dec-10 B 1 in the Reference,now I will find the exact match with PRICE 5.
For 3rd Record in the SOURCE(3-Dec-10 C 1) I don't have exact match in the Reference so I will decrement the DATE by 1 then 3-Dec-10 becomes 2-Dec-10.Now I will look for 2-Dec-10 C 1 in the Reference I don't find the exact match in the Reference.So again I need to decrement the DATE by 1 then 2-Dec-10 becomes 1-Dec-10.Now I will look for 1-Dec-10 C 1 combination match in the Reference,now I will find the exact match with PRICE 15.
Thanks & Regards,
Kalpana.