ASA Getting Started
Selecting Aggregate Data
Aggregate functions return a single value for a set of rows. If there is no GROUP BY clause, an aggregate function returns a single value for all the rows that satisfy other aspects of the query.
List the number of employees in the company
In Interactive SQL, type the following in the SQL Statements pane and press F5 to execute the statement.
SELECT COUNT( * ) FROM employee
COUNT(*) |
---|
75 |
The result set consists of only one column, with title COUNT( * ), and one row, which contains the total number of employees.
List the number of employees in the company and the birth dates of the oldest and youngest employee
In Interactive SQL, type the following in the SQL Statements pane and press F5 to execute the statement.
SELECT COUNT(*), MIN(birth_date), MAX(birth_date) FROM employee
COUNT(*) | MIN(employee.birth_date) | MAX(employee.birth_date) |
---|---|---|
75 | 1/2/1936 | 1/18/1973 |
The functions COUNT, MIN, and MAX are called aggregate functions, which are functions that summarize information. Other aggregate functions include statistical functions such as AVG, STDDEV, and VARIANCE. All but COUNT have the name of a column as a parameter.
For more information, see Aggregate functions.