db: get query for stats