How To Create a Histogram with SQL

I don't do this often enough to remember the syntax and usually google gives me more complicated solutions. So this one's for me, but maybe you'll find it useful as well.

select processorCount,count(*) from serverInventory
  where status='production'
  and os_version like 'Red%'
  group by processorCount
  order by processorCount

Results will look like this.


The bit I always forget is to include processorCount before count(*).

blog comments powered by Disqus

About Me


to this weblog's
atom feed

Recent Articles

Best Books of 2013

How to Create a Histogram with SQL

Bulletproof Coffee Redux

On Being T-Shaped