SQL to create histograms | Hacker News Reader