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 A A B B C
...戻ります:
A | 3 B | 2 C | 1
GROUPBYを使用します。
select value, count(*) from table group by value
HAVINGを使用して、結果をさらに減らします。たとえば、3回を超えて発生する値のみです。
select value, count(*) from table group by value having count(*) > 3
SELECT id,COUNT(*) FROM file GROUP BY id