Sorry, my English ability is limited, so I cannot understand long text exactly...It will be helpful with examples and samples.So, Let's tidy.# Case 1 - Simple caseCondition:Table1product type quantity pr1 2 pr1 3 pr2 10 pr2 20 pr3 1
Table2product type pr1 T2 pr1 T2 pr2 T2 pr2 T2 pr3 T3
In this case, pr1's type is T2, pr2's type is T2, pr3's type is T3.So, use previous sql to get following result.Result:product type quantity pr1 T2 2 pr1 T2 3 pr2 T2 10 pr2 T2 20 pr3 T3 1
There is no problem.# Case 2 - Puzzling caseCondition:Table1product type quantity pr1 2 pr1 3 pr2 10 pr2 20 pr3 1
Table2product type pr1 T2 pr1 T2 pr2 T2 <- * pr2 T1 <- * pr3 T3
In this case, pr1's type is T2, pr3's type is T3.However pr2's type is not deterministic, T1 or T2.So pr2's type in result cannot determin.Result:product type quantity pr1 T2 2 pr1 T2 3 pr2 ?? 10 <- * T1? T2? Which do you need? pr2 ?? 20 <- * T1? T2? Which do you need? pr3 T2 1
In this case, rule is needed to decide type.ex1. Lexicographic order, MIN(type), like following.UPDATE Table1 SET[type] = Source.[type]FROM (SELECT product, MIN([type]) [type] FROM Table2 GROUP BY product) Source
ex2. Depende on other columns not included in the sample data. If so, please show me other columns and some rule.-------------------------------------From JapanSorry, my English ability is limited.