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