last_value

Function last_value 

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

Value of argument from last row of window frame

Returns value evaluated at the row that is the last 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, last_value(id).partition_by(user_id)))
    .load::<(String, i32, i32)>(connection)?;
let expected = vec![
    ("My first post".to_owned(), 1, 2),
    ("About Rust".into(), 1, 2),
    ("My first post too".into(), 2, 3),
];
assert_eq!(expected, res);