Aggregate columns
consist of special functions that perform some calculation on a set of data.
Examples
Of aggregates
include the COUNT(), SUM(), AVG(), MIN(), STDDEV(), VAR(), and MAX() functions.
They're
Best understood by
example. Here's a command that returns the total number of customer records on
file:
SELECT COUNT(*) FROM
customers
Here's one that
returns the dollar amount of the largest order on file:
SELECT MAX(Amount)
FROM orders
And here's one that
returns the total dollar amount of all orders:
SELECT SUM(Amount)
FROM orders
Aggregate functions
are often used in tandem with SELECT's GROUP BY clause (covered below) to
produce
grouped or
partitioned aggregates. They can be employed in other uses as well (e.g., to
"hide" normally
invalid syntax), as
the chapters on statistical computations illustrate.
TSQL Tutorials..
No comments:
Post a Comment