1.4.13.7 Functions

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

max( table, column [,where=None][,values=[]])
Returns the highest value of the column.
table
The name of the table
column
The name of the column
where
An optional where clause
values
Values to substitute for ? parameters in the where clause.

min( table, column [,where=None][,values=[]])
Returns the lowest value of the column.
table
The name of the table
column
The name of the column
where
An optional where clause
values
Values to substitute for ? parameters in the where clause.

count( table, column [,where=None][,values=[]])
Count the number of rows in the table matching where. If where is not specified, count all rows.
table
The name of the table
column
The name of the column
where
An optional where clause
values
Values to substitute for ? parameters in the where clause.

For example consider the table below:

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

>>> cursor.max(table='Numbers', column='Number')
3
>>> cursor.min(table='Numbers', column='Number')
1
>>> cursor.max(table='Numbers', column='Number', where="Number<?", values=[3])
2