fix summary table sql queries. fixes #15