Revert "Revert "Merge pull request #440 from dimagi/sqlreport""

This reverts commit 01e44919990a18d034aae73c6c392b7c7c528381.
fix failing test
Merge pull request #444 from dimagi/sqlreport

reopen simon's PR that I reverted