By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Create Table table_name(Customer_nr INT, Product VARCHAR(50));
Insert Into table_name Values(11111,'Table'),
(22222,'Sofa'),
(333333,'Table'),
(444444,'Closet'),
(11111,'Bed');
5 rows affected
select t.Product Product_A, d.Product Product_B,
count(*) com_cnt
from table_name t join table_name d
on d.Customer_nr = t.Customer_nr and
d.Product > t.Product
group by t.Product, d.Product
Product_A | Product_B | com_cnt |
---|---|---|
Bed | Table | 1 |