Hi,
I have two tables: one with all items from a ERP-system (2), and one with manual correction to the items lists product hierachy (1). The manual corrections (1) can hold items which also will be found in the item list table (2).
The two tables are joined in an UNION query. My problem is that in case the item is found in both tables I only want to keep records from table (1).
So this table:
[TABLE="width: 947"]
<colgroup><col width="67" style="width:50pt"> <col width="157" style="width:118pt" span="4"> <col width="44" style="width:33pt"> <col width="74" style="width:56pt"> <col width="134" style="width:101pt"> </colgroup><tbody>[TR]
[TD="class: xl67, width: 67"]MinOfSYS[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 1[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 2[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 3[/TD]
[TD="class: xl67, width: 157"]FirstOfCOMPANY[/TD]
[TD="class: xl67, width: 44"]UNITS[/TD]
[TD="class: xl67, width: 74"]COST[/TD]
[TD="class: xl67, width: 134"]EAN[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]46,04553[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.272 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]49,163[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.289 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]50,7706[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.296 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]53,9078[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.302 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]46,04553[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.272 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]49,16308[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.289 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]50,77057[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.296 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]53,90778[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.302 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]1002,82563[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.013 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]968,89833[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.006 [/TD]
[/TR]
</tbody>[/TABLE]
Should end up like this:
[TABLE="width: 947"]
<colgroup><col width="67" style="width:50pt"> <col width="157" style="width:118pt" span="4"> <col width="44" style="width:33pt"> <col width="74" style="width:56pt"> <col width="134" style="width:101pt"> </colgroup><tbody>[TR]
[TD="class: xl67, width: 67"]MinOfSYS[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 1[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 2[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 3[/TD]
[TD="class: xl67, width: 157"]FirstOfCOMPANY[/TD]
[TD="class: xl67, width: 44"]UNITS[/TD]
[TD="class: xl67, width: 74"]COST[/TD]
[TD="class: xl67, width: 134"]EAN[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]46,04553[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.272 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]49,163[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.289 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]50,7706[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.296 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]53,9078[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.302 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]1002,82563[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.013 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]968,89833[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.006 [/TD]
[/TR]
</tbody>[/TABLE]
I have tried MIN, FIRST etc, but then I get the wrong hierachy
Any help will be much appreciated - thanks
brgds
a novice
I have two tables: one with all items from a ERP-system (2), and one with manual correction to the items lists product hierachy (1). The manual corrections (1) can hold items which also will be found in the item list table (2).
The two tables are joined in an UNION query. My problem is that in case the item is found in both tables I only want to keep records from table (1).
So this table:
[TABLE="width: 947"]
<colgroup><col width="67" style="width:50pt"> <col width="157" style="width:118pt" span="4"> <col width="44" style="width:33pt"> <col width="74" style="width:56pt"> <col width="134" style="width:101pt"> </colgroup><tbody>[TR]
[TD="class: xl67, width: 67"]MinOfSYS[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 1[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 2[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 3[/TD]
[TD="class: xl67, width: 157"]FirstOfCOMPANY[/TD]
[TD="class: xl67, width: 44"]UNITS[/TD]
[TD="class: xl67, width: 74"]COST[/TD]
[TD="class: xl67, width: 134"]EAN[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]46,04553[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.272 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]49,163[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.289 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]50,7706[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.296 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]53,9078[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.302 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]46,04553[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.272 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]49,16308[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.289 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]50,77057[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.296 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]53,90778[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.302 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]1002,82563[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.013 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]968,89833[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.006 [/TD]
[/TR]
</tbody>[/TABLE]
Should end up like this:
[TABLE="width: 947"]
<colgroup><col width="67" style="width:50pt"> <col width="157" style="width:118pt" span="4"> <col width="44" style="width:33pt"> <col width="74" style="width:56pt"> <col width="134" style="width:101pt"> </colgroup><tbody>[TR]
[TD="class: xl67, width: 67"]MinOfSYS[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 1[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 2[/TD]
[TD="class: xl67, width: 157"]FirstOfHierarchy 3[/TD]
[TD="class: xl67, width: 157"]FirstOfCOMPANY[/TD]
[TD="class: xl67, width: 44"]UNITS[/TD]
[TD="class: xl67, width: 74"]COST[/TD]
[TD="class: xl67, width: 134"]EAN[/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]46,04553[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.272 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]49,163[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.289 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]50,7706[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.296 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]1[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]AAA[/TD]
[TD="class: xl69, width: 44"]6[/TD]
[TD="class: xl69, width: 74"]53,9078[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.055.302 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]1002,82563[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.013 [/TD]
[/TR]
[TR]
[TD="class: xl68, width: 67, align: right"]2[/TD]
[TD="class: xl68, width: 157"]ABC[/TD]
[TD="class: xl68, width: 157"]DDD[/TD]
[TD="class: xl68, width: 157"]KKK[/TD]
[TD="class: xl68, width: 157"]BBB[/TD]
[TD="class: xl69, width: 44"]96[/TD]
[TD="class: xl69, width: 74"]968,89833[/TD]
[TD="class: xl75, width: 134, align: right"] 6.310.183.256.006 [/TD]
[/TR]
</tbody>[/TABLE]
I have tried MIN, FIRST etc, but then I get the wrong hierachy
Any help will be much appreciated - thanks
brgds
a novice