Summary

Today you learned to use aggregate functions to get information about a set of rows in a single row or a grouped result. Aggregates are among the most powerful and frequently used tools in Transact-SQL.

You've seen the power and flexibility of the SELECT statement extended significantly in this lesson. With grouping, ROLLUP, and CUBE, you can get grouped and totaled data. In combination with the CASE operator, you've learned to build pivot tables to deliver data in a useful format.

What all these techniques share is the capability to condense vast amounts of data into a compact result. Whenever possible, use SQL Server aggregates to reduce the size of result sets. This will improve network efficiency, reduce the work required by client applications, and improve overall system performance.

Tomorrow you will learn how to join tables together to get result sets that include data from many tables.

Here is the syntax of the SELECT statement so far:

select [distinct] <select-list>
  from <table-name>
 where <condition-expression>
 [ and | or <condition-expression> … ]
 group by <group-expression>
 [ , <group-expression> … ]
     [ with rollup | cube ]
having <condition-expression>
 [ and | or <condition-expression> … ]
 order by <sort-expression> [asc | desc]
 [ , <sort-expression> [asc | desc] … ]

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset