Asp+sql Server 2005 Text field column value sum

Source: Internet
Author: User

The original planning number field is text. Format without changing the type

SUM (CAST (number As Integer))

Instance code:

The code is as follows Copy Code

<%set mrs=server.createobject ("Adodb.recordset")
Msql= "Select SUM (CAST (field name as Integer)" from table name where conditional language name "
Mrs.open msql,conn,1,3
Response.Write MRs (0)
Mrs.close
Set mrs=nothing
%>

Here are some numbers to sum

Use the sum (SUM) function
The SUM function is used to return all the values in an expression

A few notes used by the SUM function:
(1) fields that contain indexes can speed up the operation of aggregate functions. The SUM function is available for fields with the
(2) field data type int, smallint, tinyint, decimal, numeric, float, real, money, and smallmoney.
(3) when using the SUM function, SQL Server treats the smallint or tinyint these data types as int in the result set.
(4) When the SUM function is used, SQL Server ignores null values (NULL), that is, the null values are not computed.

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.