Rewrite of the statistic get query.