Counting the instances of customers

Posted by Mikae Combarado on Stack Overflow See other posts from Stack Overflow or by Mikae Combarado
Published on 2010-06-15T15:57:37Z Indexed on 2010/06/15 16:02 UTC
Read the original article Hit count: 130

Filed under:
|

Say that I have a table with one column named CustomerId. The example of the instance of this table is :

CustomerId
14
12
11
204
14
204

I want to write a query that counts the number of occurences of customer IDs. At the end, I would like to have a result like this :

CustomerId      NumberOfOccurences
14              2
12              1
11              1
204             2
14              1

I cannot think of a way to do this.

© Stack Overflow or respective owner

Related posts about sql

Related posts about group-by