first_value

Function first_value 

Source
pub fn first_value<T: SqlType + SingleValue, value>(
    value: value,
) -> first_value<T, <value as AsExpression<T>>::Expression>
where value: AsExpression<T>,
Expand description

Value of argument from first row of window frame

Returns value evaluated at the row that is the first row of the window frame.

This function must be used as window function. You need to call at least one of the methods WindowExpressionMethods from to use this function in your SELECT clause. It cannot be used outside of SELECT clauses.

let res = posts
    .select((title, user_id, first_value(id).partition_by(user_id)))
    .load::<(String, i32, i32)>(connection)?;
let expected = vec![
    ("My first post".to_owned(), 1, 1),
    ("About Rust".into(), 1, 1),
    ("My first post too".into(), 2, 3),
];
assert_eq!(expected, res);