My challenging challenge for today is: how to achieve Desired Output Table from Input Table:
DECLARE @table1 TABLE
(
[Sub1] CHAR(1),
[Sub2] CHAR(1)
);
INSERT INTO @table1
VALUES
('A', 'B'),
('A', 'D'),
('A', 'F'),
('A', 'E'),
('A', 'A'),
('A', 'C'),
('A', 'G'),
('C', 'A'),
('B', 'A'),
('X', 'Z');
select * from @table1;
The idea is: all elements (from A to G) are substitutes:
B replaces A, E replaces A so B replaces not only A but E as well and so on. However X and Z substitute only each other - none of them has connection to any others of elements.
Finally I would like to have all parts listed and their possible substitutes.
I would greatly appreciate any suggestion on that.