rudimentary sql stats impl