activity_count in stored procedure