Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 2 Queries: Selecting Data from
a Table [Table of Contents] Chapter 4 Joins: Retrieving Data from Several
Tables

Transact-SQL User's Guide

[-] Chapter 3 Using Aggregates, Grouping, and Sorting

Chapter 3

Using Aggregates, Grouping, and Sorting

This chapter addresses the sum, avg, count, count(*), max, and min aggregate functions that enable you to summarize the data retrieved in a query. This chapter also discusses how to organize data into categories and subgroups using the group by, having, and order by clauses. Two Transact-SQL extensions--the compute clause and the union operator, are also discussed.

If your Adaptive Server is not case sensitive, see group by and having Clauses and compute Clause in the Reference Manual for examples on how case sensitivity affects the data returned by these clauses.

[-] Using aggregate functions
Aggregate functions and datatypes
count vs. count (*)
Using aggregate functions with distinct
Null values and the aggregate functions
[-] Organizing query results into groups: the group by clause
[+] group by syntax
Referencing other columns in queries using group by
Expressions and group by
Nesting aggregates with group by
Null values and group by
where clause and group by
group by and all
Using aggregates without group by
[-] Selecting groups of data: the having clause
How the having, group by, and where clauses interact
Using having without group by
[-] Sorting query results: the order by clause
order by and group by
order by and group by used with select distinct
[-] Summarizing groups of data: the compute clause
[+] Row aggregates and compute
Specifying more than one column after compute
Using more than one compute clause
Applying an aggregate to more than one column
Using different aggregates in the same compute clause
Grand values: compute without by
[-] Combining queries: the union operator
Guidelines for union queries
Using union with other Transact-SQL commands


Pattern matching [Table of Contents] Using aggregate functions