Skip to content
basic aggregate functions

Introducing: max()


This simple query will display the kms column from all the table rows.
select kms from route
Loading…

Suppose the requirement was simply:
What distance is the longest route?

Here is a query which uses the aggregate function max()
select max(kms) as "Longest distance" from route
Loading…

The query uses an alias to create a helpful heading.
Only one row is returned: there can only be one top value (although it could appear in more than 1 row).
There is a matching min() function which is used in the same way and returns the smallest value.

Using max() and min() aggregate function


save your working code in application express
Try a simple version first, like: display all rows and columns. Then introduce max() or min(), then add an alias

How long does the quickest route take to complete?
How many people went on the busiest walk?
What was the smallest group of people who went out in the rain?

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.