create table dbo.tableinfo
(
list1 varchar(10),
list2 varchar(10),
Num int
)
insert into dbo.tableinfo values
('A','A',5),
('A','B',2),
('A','C',7),
('A','D',2),
('B','A',2),
('B','B',4),
('C','A',7),
('C','B',6),
('C','C',7),
('C','D',8),
('C','E',3),
('D','A',2),
('D','B',5),
('D','C',8)
Expected out put is as following:
A B 2
A C 7
A D 2
C B 6
C D 8
C E 3
D B 5
Condition1, is do not display same same in list1 and list2, eg A A 5
condition2, is do not display "A B 2" and "B A 2" twice, show any one only once.