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(*).

Jeremy Ulstad

Dad, IT Architect, Musician, Sailor

Minneapolis, Minnesota http://jeremyulstad.com