Skip to main content

Posts

Showing posts with the label mysql

How to get a frequency distribution table in MySQL

Sometimes when we are searching for something, we tend to look too deep and with wrong keywords. Forget about SQL procedures, the REPEAT() function and setting variables. If you want a result set with two columns, one the ID, and the other a frequency count, then use this: SELECT id, COUNT( someValue ) AS frequency FROM tableName GROUP BY someValue; Your welcome!