It is not difficult to determine how many records exist in the database or determine how many records meet certain standards. If you use the correct cursor type, you can use the RecordCount attribute to obtain the number of records. Of course, you can also use recordset. However, there is a simpler way to use count (*) in your SELECT statement. The code is as follows:
SQL = "SELECT count (*) FROM MERS"
Or
SQL = "SELECT count (*) FROM MERS WHERE c_lastname LIKE 'a % '"
For example, the following code selects some records and the total number of these records:
SQL = "SELECT c_firstname, c_lastname, count (*) FROM MERS WHERE c_lastname LIKE 'a % '"
However, you cannot achieve your goals. Here, the "count" function is actually a set function, meaning that only the single row information is returned: To answer your question. The question for the 1st SELECT statements is "how many records are there in the customer table ?" The query returns a single value as a response, so it cannot be combined with your regular query. If you want to get other data, you need to use RecordCount.
In addition to "count", aggregate functions include AVG, MIN, MAX, and SUM.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.