ODBC and JDBC Guide

Table Of Contents
Chapter 7 | Supported standards 46
In this example, only unique last name values are counted.
Examples
SELECT SUM (Sales_Data.Amount) AS agg FROM Sales_Data
SELECT AVG (Sales_Data.Amount) AS agg FROM Sales_Data
SELECT COUNT (Sales_Data.Amount) AS agg FROM Sales_Data
SELECT MAX (Sales_Data.Amount) AS agg FROM Sales_Data
WHERE Sales_Data.Amount < 3000
SELECT MIN (Sales_Data.Amount) AS agg FROM Sales_Data
WHERE Sales_Data.Amount > 3000
SQL expressions
Use expressions in WHERE, HAVING, and ORDER BY clauses of SELECT statements to form
detailed and sophisticated database queries.Valid expression elements are:
1 Field names
1 Constants
1 Exponential notation
1 Numeric operators
1 Character operators
1 Date operators
1 Relational operators
1 Logical operators
1 Functions
Field names
The most common expression is a simple field name, such as calc or Sales_Data.Invoice_ID.
Aggregate function Returns
SUM The total of the values in a numeric field expression. For example, SUM(SALARY) returns
the sum of all salary field values.
AVG The average of the values in a numeric field expression. For example, AVG(SALARY)
returns the average of all salary field values.
COUNT The number of values in any field expression. For example, COUNT(NAME) returns the
number of name values. When using COUNT with a field name, COUNT returns the number
of non-null field values. A special example is COUNT(*), which returns the number of
records in the set, including records with null values.
MAX The maximum value in any field expression. For example, MAX(SALARY) returns the
maximum salary field value.
MIN The minimum value in any field expression. For example, MIN(SALARY) returns the
minimum salary field value.