Counting instances of unique value in a field

Suppose you have a table in SQL:

Prices
------
13.99
14.00
52.00 
52.00 
52.00 
13.99

How could you count the number of times the DIFFERENT field was entered? Therefore, an example of such a calculation displays:

13.99 - 2 times. 
14.00 - 1 times. 
52.00 - 3 times.

OR, possibly:

3 (i.e. 13.99, 14.00, 52.00)

Can anyone advise? Greetings.

+3
source share
1 answer

What about:

SELECT Prices, COUNT(*) FROM TheTable GROUP BY Prices

I can’t say that I tried this on MySql, but I would expect it to work ...

+8
source

Source: https://habr.com/ru/post/1720759/


All Articles