Column Functions

The column functions that act on the groups are:

For example, to print each order number and the total quantity for that order:

SELECT order_number, SUM(quantity)
FROM order_line
GROUP BY order_number;

To count the number of records in a group:

SELECT COUNT(*) FROM customer;

where COUNT(*) counts the number of customers (as there is no GROUP BY here, the whole customer table is treated as a single group).

The word DISTINCT may be included in the argument of a column function to cause it to ignore duplicate values; for example:

COUNT(DISTINCT name)

counts the number of different values for NAME.