こんな感じで
SQL
1create table tbl(
2 user_id int,
3 savings int,
4 created_at datetime,
5 unique(user_id,created_at));
6insert into tbl values
7(1,100,'2023-01-01 00:00:00'),
8(1,200,'2023-01-01 01:00:00'),
9(1,150,'2023-01-01 02:00:00'),
10(2,100,'2023-01-01 00:00:00'),
11(2,110,'2023-01-01 10:00:00'),
12(3, 0,'2023-01-01 01:00:00'),
13(3,500,'2023-01-01 02:00:00'),
14(3,100,'2023-01-01 03:00:00');
15
16select * from tbl as t1
17where not exists(
18 select 1 from tbl
19 where user_id=t1.user_id and created_at>t1.created_at
20 );
21