Hi,
Please find the tables…
ID,PRDID,NAME,INERNAL,BRANDED,PREFERRED,REGION,PRICE
213,1045,AAA,Y,Y,Y
213,1528,AAA,Y,N,N
227,1524,BBB,Y,Y,Y
227,1744,BB,N,N,N
227,1967,BBB,N,YN
TABLEB
PRDID,REGION,PRICE
1045,EAST,0.0
1528,EAST,1.0
1528,NORTH,1.0
1524,WEST,0.0
1744,WEST,1.0
1744,EAST,1.0
1744,EAST,0.0
1967,WEST,0.0
1967,WEST,12.0
1967,EAST,12.0
I dont know wheather by joinning I am getting closer or making more complex…
ID,PRDID,NAME,INERNAL,BRANDED,PREFERRED,REGION,PRICE
213,1045,AAA,Y,Y,Y,EAST,0.0
213,1528,AAA,Y,N,N,EAST,1.0
213,1528,AAA,Y,N,N,NORTH,1.0
227,1524,BBB,Y,Y,Y,WEST,0.0
227,1744,BB,N,N,N,WEST,1.0
227,1744,BB,N,N,N,EAST,1.0
227,1744,BB,N,N,N,EAST,0.0
227,1967,BBB,N,YN,WEST,0.0
227,1967,BBB,N,YN,WEST,12.0
227,1967,BBB,N,YN,EAST,12.0
Please find the conditions and the tabels along with output expected…
Conditions:
- if the only record returned is a Branded line (where Branded = Y) then use; otherwise ignore Branded lines
- Where there is a line where all three flag fields are Y (line 1 in the example below), match this line first in the table B,
- If first selected record from the group has no price value in the TABLEB then take second record from the group of tableA and get the price from the TABLEB. If you dont find price for all fields having Y and Branded having Y then take the record which has all NNN and try to get the price from TABLEB
TABLEA
PRDID,ID,Name,Branded,Prefered,Internal
20044,1001191,AAA,Y,Y,Y
20044,1010246,AAA,Y,N.N
20287, 1005666,NNN,Y,N,N
20287, 1012251,NNN,Y,N,N
20287, 1012821,NNN,N,N,N
20289, 1012824,MMM,Y,N,N
TABLEB
ID,REGION,PRICE,QUANTITY
1001191,W,1.8,28
1001191,E,1.9,28
1010246,NULL,0,0
1005666,W,0.0
1012251,S,2.3,1
1012251,E,2.3,1
1012821,W,0,0
1012824,S,1.2,1
OUTPUT
PRDID,ID,NAME,REGION,PRICE,QUANTITY
20044,1001191,AAA,W,1.8,2.8
20044,1001191,AAA,E,1.9,28
20287, 1012251,NNN,S,2.3,1
20287, 1012251,NNN,E,2.3,1
20289, 1012824,MMM,S,1.2,1
At the end I need to create XML…
Please adive how to achieve above…
Thanks
Rajeev
rajeev_mdm (BOB member since 2011-01-16)