If anyone is still looking for it and the accepted answer doesn't fit (query planner shenanigans) MariaDB has LAST_VALUE() function specifically for this.
LAST_VALUE()
https://mariadb.com/kb/en/last_value/