added countBySubQuery method for record service