last¶
Description¶
Return the last value of one column across an ordered group. If no ordering is specified, the default ordering is that of the invoking verb, which is generally the ‘valid_from’ timestamp, ascending. In this case, the last value is the latest.
Return type¶
storable value
Domain¶
This is an aggregate function (aggregates rows over a group in aggregate verbs.)
This is a window function (calculates over a group of multiple input rows using windowing.)
Categories¶
Usage¶
last( expression [ , order_by ] )
Argument |
Type |
Required |
Multiple |
Constant |
---|---|---|---|---|
expression |
variant |
Required |
Only one |
Variable |
order_by |
ordering |
Optional |
Only one |
Variable |
Examples¶
make_col last_customer:window(last(customer_id), group_by(category))
Find out the customer that appears last within each category.
statsby last_customer:last(customer_id), group_by(category)
Find out the customer that appears last within each category.
statsby first_customer:last(customer_id, order_by(login_time)), group_by(category)
Find out the customer that logged in last within each category.