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.