SQL computing problems

Source: Internet
Author: User

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!

Related Article

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.