1.4.4.9 Functions

The cursor objects currently support two function methods: max() and min() as described below.

max( field, table[,where=None])
Returns the highest value of the field.
field
The name of the field
table
The name of the table
where
An optional where clause

min( field, table[,where=None])
Returns the lowest value of the field.
field
The name of the field
table
The name of the table
where
An optional where clause

For example consider the table below:

# Numbers
+--------+
| Number |
+--------+
| 1      |
+--------+
| 2      |
+--------+
| 3      | 
+--------+

>>> cursor.max('Number', 'Numbers')
3
>>> cursor.min('Number', 'Numbers')
1
>>> cursor.max('Number', 'Numbers', where="Number<3")
2

See About this document... for information on suggesting changes.