Fix issue with count query and table name