use the new count method to construct sql statement.