class Least(*expressions, **extra)
[source]
New in Django 1.9.
Accepts a list of at least two field names or expressions and returns the least value. Each argument must be of a similar type, so mixing text and numbers will result in a database error.
Warning
The behavior of Least
when one or more expression may be null
varies between databases:
- PostgreSQL:
Least
will return the smallest non-null expression, ornull
if all expressions arenull
. - SQLite, Oracle, and MySQL: If any expression is
null
,Least
will returnnull
.
The PostgreSQL behavior can be emulated using Coalesce
if you know a sensible maximum value to provide as a default.
Please login to continue.