Hi all,
I'm trying to combine two different data sources. Unfortunately, since I'm quite new to Access, I don't seem to be able to figure it out. I have the following two tables that I need to combine:
Raw Data Table:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Store ID[/TD]
[TD]Store Name[/TD]
[TD]Store Type[/TD]
[TD]Retail Channel[/TD]
[TD]SLS RTL[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]2500[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]4500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]3250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]675[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]550[/TD]
[/TR]
</tbody>[/TABLE]
LookUp Table:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Store ID[/TD]
[TD]Provin[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]Guangxi[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]Zhejiang[/TD]
[/TR]
</tbody>[/TABLE]
Now I want to create a Query from both tables, matching the correct Province for each Store ID in my Raw Data table and fill a blank or zero if there's no match. So the result should be something like this:
[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Store ID[/TD]
[TD]Store Name[/TD]
[TD]Store Type[/TD]
[TD]Retail Channel[/TD]
[TD]Province[/TD]
[TD]SLS RTL[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]Guangxi[/TD]
[TD]2500[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]Guangxi[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]Guangxi[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]4500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]3250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]Zhejiang[/TD]
[TD]675[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]Zhejiang[/TD]
[TD]550[/TD]
[/TR]
</tbody>[/TABLE]
How can I achieve that? I tried with below, but that doesn't seem to work...
I'm trying to combine two different data sources. Unfortunately, since I'm quite new to Access, I don't seem to be able to figure it out. I have the following two tables that I need to combine:
Raw Data Table:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Store ID[/TD]
[TD]Store Name[/TD]
[TD]Store Type[/TD]
[TD]Retail Channel[/TD]
[TD]SLS RTL[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]2500[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]4500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]3250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]675[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]550[/TD]
[/TR]
</tbody>[/TABLE]
LookUp Table:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Store ID[/TD]
[TD]Provin[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]Guangxi[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]Zhejiang[/TD]
[/TR]
</tbody>[/TABLE]
Now I want to create a Query from both tables, matching the correct Province for each Store ID in my Raw Data table and fill a blank or zero if there's no match. So the result should be something like this:
[TABLE="class: grid, width: 600"]
<tbody>[TR]
[TD]Store ID[/TD]
[TD]Store Name[/TD]
[TD]Store Type[/TD]
[TD]Retail Channel[/TD]
[TD]Province[/TD]
[TD]SLS RTL[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]Guangxi[/TD]
[TD]2500[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]Guangxi[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]30001[/TD]
[TD]NANNING MIXC[/TD]
[TD]FSS[/TD]
[TD]RLS[/TD]
[TD]Guangxi[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]4500[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]3250[/TD]
[/TR]
[TR]
[TD]60002[/TD]
[TD]GRAND GATEWAY[/TD]
[TD]SIS[/TD]
[TD]RLC[/TD]
[TD][/TD]
[TD]150[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]Zhejiang[/TD]
[TD]675[/TD]
[/TR]
[TR]
[TD]80003[/TD]
[TD]HANGZHOU XIAOSHAN[/TD]
[TD]FSS[/TD]
[TD]RLE[/TD]
[TD]Zhejiang[/TD]
[TD]550[/TD]
[/TR]
</tbody>[/TABLE]
How can I achieve that? I tried with below, but that doesn't seem to work...
Code:
SELECT D.Store ID, D.Store Name, D.Store Type, D.Retail Channel, L.Province, D.SLS RTLFROM Raw Data AS D, LookUp AS L
INNER JOIN LookUp
ON D.Store ID=L.Store ID