SQL version of existing psi custom-reports