开发者

Number of times a record shows up : SQL Server

开发者 https://www.devze.com 2023-03-09 23:55 出处:网络
I have a table with just one field, say Numbers. And it looks like this: Numbers 1 1 1 2 2 2 3 3 3 3 3 4 4 4 4 What I want is an output of the number o开发者_如何学JAVAf times each number shows up.

I have a table with just one field, say Numbers. And it looks like this:

Numbers
1
1
1
2
2
2
3
3
3
3
3
4
4
4
4

What I want is an output of the number o开发者_如何学JAVAf times each number shows up. For example, 1 has a count of 15, 2 has a count of 33 and so on.

What is the query I would run to identify the number of occurrences?


select Numbers, count(*) as Count
from MyTable
group by Numbers


SELECT Numbers, Count(Numbers)
    FROM YourTable
    GROUP BY Numbers


SELECT Numbers, COUNT(1) FROM Table GROUP BY Numbers

0

精彩评论

暂无评论...
验证码 换一张
取 消