Counting Instances of Unique Value in Field

北慕城南 提交于 2019-12-21 17:37:46

问题


Suppose you have a table in SQL:

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

How would you count the amount of times a DIFFERENT field has been entered in? Therefore an example of such a count would output:

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

OR perhaps:

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

Can anyone advise? Cheers.


回答1:


How about:

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

Can't say I've tried it on MySql, but I'd expect it to work...



来源:https://stackoverflow.com/questions/1605886/counting-instances-of-unique-value-in-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!