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.

22005
4166
859

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

blog comments powered by Disqus

About Me

Subscribe

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

Rudderectomy