U
U
user.2018-12-02 23:05:38
SQL
user., 2018-12-02 23:05:38

SQL how to implement counting the number of identical values ​​in a column?

Knowledgeable people tell me.
There is a column of the form:
1
1
1
2
2
2
3
3
3
3
How to get the output: number of units: 110 number of twos: 120 number of triples: 120

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Planet_93, 2018-12-03
@Planet_93

If we have such a table:
Then, by executing such a query:

SELECT 
MAX(num) AS Name, 
COUNT(num) AS Count

FROM
dbo.TestTable
GROUP BY (num)

we get:
5c04d9ead2c73412386993.jpeg

R
Rsa97, 2018-12-02
@Rsa97

COUNT ... GROUP BY

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question