analytics: fix various bugs in SqlDao layer

Signed-off-by: Pierre-Alexandre Meyer <pierre@ning.com>
Merge branch 'master' of github.com:killbill/killbill