Item1 Item2 Value Apple Orange 3 Apple Banana 2 Mango Apple 2 Banana Apple 6 Apple Mango 5 Orange Banana 4 Orange Apple 5
Item1 Item2 Value Apple Orange 8 Apple Banana 8 Mango Apple 7 Orange Banana 4
select T1.item1 ,T1.Item2, sum(T1.Value) from MyDB as T1 join MyDB as T2 on T1.item1 = T2.item2 group by item1,item2 ;
SELECT LEAST(Item1, Item2) AS Item1, GREATEST(Item1, Item2) AS Item2, SUM(Value) AS Value FROM yourTable GROUP BY 1, 2;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)