Skip to main content

count

Function count 

Source
pub fn count<'a, V, A>(
    arg: A,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::BigInt, NonNull, Agg, ScopeOnly<A::Sources>>
where V: SQLParam + 'a, A: CountArg<'a, V>,
Expand description

Row or value count (COUNT).

count(()) renders COUNT(*) and counts rows. count(expr) renders COUNT(expr) and counts non-NULL values. The result is the dialect’s big-integer type, never NULL, and an aggregate.

§Examples

assert_eq!(count::<Value, _>(()).sql(), "COUNT(*)");
assert_eq!(count(users.email).sql(), r#"COUNT ("users"."email")"#);