SQL代码示例:
SELECT column1, COUNT(DISTINCT column2) FROM table GROUP BY column1;
Python pandas示例:
result = table.groupby('column1')['column2'].nunique().reset_index(name='count')
上一篇:按组选择第一行和满足条件的另一行
下一篇:按组选择每个运行的第一行