Revert "SQL query fix for statistic"

This reverts commit 00dcd817ce5adad3045565e4db88afe1c2b258dd.