How to create a Histogram in SQL