Использовать самостоятельное соединение:
select t1.product, t2.product, count(*)
from t t1 join
t t2
on t1.id = t2.id and t1.product < t2.product
group by t1.product, t2.product;
. Наборы элементов помещаются в два столбца.Вы также можете объединить их вместе:
select t1.product || ',' || t2.product, count(*)
from t t1 join
t t2
on t1.id = t2.id and t1.product < t2.product
group by t1.product, t2.product
order by t1.product || ',' || t2.product;
Здесь - это скрипта SQL, иллюстрирующая, что код работает.