Search code examples
sqlrelational-databasesap-ase

Count of repeated column values in Sybase


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


Solution

  • Yous should use group by clause as below

    select col2, count(col2)
    from tab
    group by col2