How to find the number of rows matching a value
The result of a search is the number of matching rows.
set count [$table search -compare {{= fieldname value}}]
How to find the lowest (highest) value of a field
Sort by the field name, with a limit of 1.
# To find the lowest value, sort ascending.
$table search -fields fieldname -get row -sort fieldname -limit 1 -code {
set lowest [lindex $row 0]
}
# To find the highest value, sort descending
$table search -fields fieldname -get row -sort -fieldname -limit 1 -code {
set lowest [lindex $row 0]
}