WIP implementing sql histograms