How to count number of occurrences for all different values in database column?
Group by the column you are interested in and then use count to get the number of rows in each group:
SELECT column5, COUNT(*)
FROM table1
GROUP BY column5
Use the GROUP BY
clause and the COUNT()
aggregate function:
SELECT column5, COUNT(column5) AS Occurences
FROM myTable
GROUP BY column5