I have a requirement wherein I have to find how many times a particular column has repeated. For Example:

Col1 | Col2
------------
1    |2
2    |2
3    |3
4    |3
5    |3

in the above table, value '2' in the column is repeated twice and value '3' is repeated thrice. I want to know a way to find this

有帮助吗?

解决方案

Yous should use group by clause as below

select col2, count(col2)
from tab
group by col2 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top