SQL · Functions and expressions

Greatest / least

Returns the largest or smallest of the arguments. PostgreSQL and SQLite differ in null handling.

Syntax
greatest(a, b)

Example

Open in the lab

Notes

SQLite uses max()/min() with multiple arguments; PostgreSQL uses GREATEST/LEAST.

More in this group

cast() concat() cte current_date / now() date_trunc() exists extract() lag() / lead()

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course