Using SQL statements in ASP 11: Record statistics

Source: Internet
Author: User
Statistics | Statements determine how many records are in the database, or determine how many records meet certain standards, which are not difficult to accomplish with ASP. If you use the correct cursor type, you can use the RecordCount property to get the number of records, of course, with the recordset. But there's a simpler way to do this is to take count (*) in your own SELECT statement, and the code looks like this:
SQL = "SELECT count (*) from Customers"

Or
SQL = "SELECT count (*) from Customers 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 Customers WHERE c_lastname like ' a% '"

But you can't achieve your purpose. The "Count" function here is actually an aggregate function, meaning to return only one line of information: Answer the question you asked. For the 1th SELECT statement, the question 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 queries." If you want to get other data, you need to use RecordCount.

Aggregate functions include AVG, MIN, Max, and sum, in addition to count.



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.