refactor reports sql
Merge pull request #708 from adrianob/refactor_report_sql

refactor reports sql