Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有表格:
A 2 A 2 A 2 A 2 A 3 A 4 A 4 A 4
我想要表单的输出:
A 2 3 A 3 1 A 4 2
对这个问题最有效的查询是什么?
select col1, col2, greatest(count(*) - 1, 1) from your_table group by col1, col2