O'Reilly logo

Microsoft® SQL Server™ 2000 Programming by Example by Carlos Eduardo Rojas, Fernando G. Guerrero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The COMPUTE Clause

In Chapter 4, you learned how to use aggregate functions to produce summary data. Queries using aggregate functions show only summary information by grouping data.

The Transact-SQL COMPUTE clause provides the capability to create reports that show detailed and summary information.

Caution

COMPUTE is not an ANSI standard feature.

To add summary information to any standard query, just add the COMPUTE clause at the end of the query, specifying which aggregate function to compute, as in Listing 11.18.

Code Listing 11.18. Use COMPUTE to Show Summary Information at the End of a Standard Query
					 -- This is a normal query to retrieve ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required