HOWTO: Use ADO to Return a Summary Row (194005)
The information in this article applies to:
- Microsoft Active Server Pages
- ActiveX Data Objects (ADO) 1.5
- ActiveX Data Objects (ADO) 2.0
- ActiveX Data Objects (ADO) 2.1 SP2
- ActiveX Data Objects (ADO) 2.5
- ActiveX Data Objects (ADO) 2.6
- ActiveX Data Objects (ADO) 2.7
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Server 5.0
- Microsoft Data Access Components 1.5
- Microsoft Data Access Components 2.0
- Microsoft Data Access Components 2.1 SP2
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
This article was previously published under Q194005 SUMMARY
The sample code in this article demonstrates how to extract the value of
summary rows using ADO. Summary rows are produced when you use a COMPUTE BY
clause with any row aggregate functions in a SQL statement. These summary
values appear as additional rows in the query results, unlike the aggregate
function results of a GROUP BY clause, which appear as new columns.
For example, the following query returns the summation for the "price" and
"advance" columns in addition to the columns in the SELECT clause:
SELECT type, price, advance
FROM titles
ORDER BY type
COMPUTE SUM(price), SUM(advance) BY type
If you create a recordset based on this SQL statement, and if you loop
through the recordset, you can only see the columns specified in the SELECT
clause. This is because ADO returns the results of a query with a COMPUTE
statement as multiple recordsets. To get the summary rows, you must loop
through each recordset from the multiple recordsets.
REFERENCES
For additional information on retrieving Multiple Recordsets, please see
the following article in the Microsoft Knowledge Base:
182290
HOWTO: Return Multiple Recordsets with Column Names and Values
Modification Type: | Minor | Last Reviewed: | 3/14/2005 |
---|
Keywords: | kbCodeSnippet kbDatabase kberrmsg kbhowto kbScript KB194005 |
---|
|