Skip to main content

greatest

Function greatest 

Source
pub fn greatest<'a, V, L, R>(
    left: L,
    right: R,
) -> SQLExpr<'a, V, L::SQLType, <L::Nullable as NullAnd<R::Nullable>>::Output, <L::Aggregate as AggOr<R::Aggregate>>::Output>
Expand description

GREATEST - returns the largest of the given values (PostgreSQL).

Both arguments must have compatible types. PostgreSQL ignores NULL inputs, so GREATEST(1, NULL) returns 1. The result is only NULL when all inputs are NULL.

ยงExample

use drizzle_core::expr::greatest;

// Clamp to minimum of 0
let score = greatest(users.score, 0);