--A=100,B=50,C=200
DECLARE @T1 TABLE (CAT1 VARCHAR(1),CAT2 VARCHAR(1),MinVal int)
INSERT INTO @T1
SELECT 'A','A',100
UNION ALL
SELECT 'A','B',50
UNION ALL
SELECT 'A','C',100
UNION ALL
SELECT 'B','A',50
UNION ALL
SELECT 'B','B',50
UNION ALL
SELECT 'B','C',50
Union all
SELECT 'C','A',100
UNION ALL
SELECT 'C','B',100
UNION ALL
SELECT 'C','C',200
select * from @T1
I have to calculate sum of MinValue which should include only (AB,AC,BC) as whatever min of AB=BA so need to take one only.
so in result i want to get 3 rows out of 9.
Cat1|Cat2|MinVal
A|B|50
A|C|100
B|C|50
Any help will be highly appreciated.
Earlier i tried the things below but it did not work.
Select * from @T1 where Cat1<>Cat2 and ?
(what condition i need to write to avoid undesired combination.)
Here's a link