我有一个这样的数据集:
这是我期待的输出:
请在 BiqQuery 中提供您非常感谢的帮助,因为这是在 GCP 中完成的。
尝试以下简单方法
select format('%s, %s', a.fruit, b.fruit) combination, count(distinct a.person) unique_person_count from your_table a join your_table b on a.person = b.person and a.fruit < b.fruit group by combination order by unique_person_count desc
如果应用于您问题中的样本数据 - 输出为