Aggregate functions for computing in SQL statements:
COUNT (*): calculates the number of tuples.
COUNT (<column Name>
SUM/AVG/MAX/MIN (<column Name>): Calculate the SUM, average, maximum, and minimum values of a column (numeric type)
Let's analyze the types of computing problems that we often encounter.
1: calculate the number of tuples (records). For example, if you are currently on the machine, you need to query and display them in the machine table.
Here we can solve the problem by using the attributes of the object:
Dim mrc as adodb. recordset
Dim count as integercount = mrc. recordcount is assigned to a variable and displayed.
2. Calculate the sum of the values of a column. For example, we need to calculate the total deposits of all registered cards.
In this case, we can find the table to be calculated and traverse all values of the columns to be summarized.
Dim mrc as adodb. recordsetdim txtSQL as stringdim msgText as stringdim countMoney as longtxtsql = "select * from registcard_info" set mrc = executesql (txtsql, msgtext) countmoney = 0do while mrc. eof countmoney = countmoney + mrc! Money' if you know which column it is, you can use the field attribute to represent mrc. movenextloop.
The above are just a few lines of code temporarily written. Many naming rules are not standard. Please forgive me!
At present, the above two situations are mainly involved in data processing of the data room charging system. We will discuss the situation in the future, update it, and discuss it!