hanchilicious
Programmer
Hi,
Can you help me figure this out?
I have a table which looks a bit like this:
TABLE_A
And another table which looks like this:
TABLE_B
Here's the issue:
I need to use a full join to join these two tables together, as there are exclusive rows in each. The join is based on the columns with values 800 and PPM%.
If I do a straight full join based on these two columns, I'm going to get four instances of the TABLE_B join, when there is in fact only one.
TABLE_A.Col6 is stopping me from being able to 1-to-1 join at 800 and PPM level. How do I go about just joining to one row? (Which one of the four isn't important).
I'm currently doing:
But even though these are distinct dimensions, the subquery returns more than one value due to the measure difference. And I can't group by measures...
Can you help me figure this out?
I have a table which looks a bit like this:
TABLE_A
Code:
Col1 Col2 Col3 Col4 Col5 Col6 Col7 Col8
----------------------------------------------------------------------------
800 UK ACCESSORIES PPM9572 Not assigned 200225 IN02 50
800 UK ACCESSORIES PPM9572 Not assigned 200430 IN02 40
800 UK ACCESSORIES PPM9572 Not assigned 903183 IN02 20
800 UK ACCESSORIES PPM9572 Not assigned 903572 IN02 50
And another table which looks like this:
TABLE_B
Code:
Col1 Col2 Col3 Col4
----------------------------
800 UK PPM9572 400
I need to use a full join to join these two tables together, as there are exclusive rows in each. The join is based on the columns with values 800 and PPM%.
If I do a straight full join based on these two columns, I'm going to get four instances of the TABLE_B join, when there is in fact only one.
TABLE_A.Col6 is stopping me from being able to 1-to-1 join at 800 and PPM level. How do I go about just joining to one row? (Which one of the four isn't important).
I'm currently doing:
Code:
FULL OUTER JOIN TABLE_B
ON TABLE_A.Col1 = TABLE_B.Col1
AND TABLE_A.Col4 = TABLE_B.Col4
AND TABLE_A.Col6 =
(select max(Col6) from TABLE_A
group by Col1,Col4,Col8)