Skip to main content

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!


Popular posts from this blog

But Google what about mobile phones that do not support Javascript?

In the global device market, there are still between 0.2% and 5.4% of phones that do not support Javascript, at least in these set of countries according to this site. In case your mobile website falls within this set than what do you do when you want to optimize CSS delivery by deferring the loading of some CSS but still serving the complete CSS to non-Javascript websites?

Fudgie's glTail with Chipmunk on MS Windows!

Hey folks, It has been a while. Recently I have been busy with other stuff besides the usual, but a friend of mine suggested (and I completely agree) to be a good utilitarian and post something that will bring the greatest happiness for the greatest number of users :)

A Short Online Letter to the Board of Alphabet Inc.

Dear Chairman Hennessy, I would like to openly share a question that kept coming back to me in the past couple of days, and that gave me courage to write a short open letter for the first time in my life. While catching up with daily news I came across a couple of articles in the past week alone, namely on the world’s remaining wilderness areas that are under threat . That the Earth’s oceans have retained 60 percent more heat each year than we’ve previously thought, that humanity has wiped out 60% of animal populations since 1970, that China has legalised rhino horn and tiger bone usage after 25 years, to calling for urgent action to develop technologies for negative emissions because our clean energy efforts won’t be enough. Here’s the question: is there actually a future for us, for your company, for humanity and our natural environment? What we do today will lay down the trajectory for our carrying capacity on Earth. Instead of investing in self-driving transportation and