Это дает те же результаты, хотя выглядит как basi c код:
declare @table table (test_id int,test_date date,test_date_from date,cash_per_step float)
insert into @table
(test_id,test_date,test_date_from,cash_per_step)
values
(1,'2020-01-01','2019-12-30',30)
, (1,'2020-01-21','2019-12-30',40)
, (1,'2020-02-28','2019-12-30',30)
, (2,'2020-01-01','2019-12-30',30)
, (2,'2020-01-21','2019-12-30',40)
, (2,'2020-02-28','2019-12-30',30);
select
test_id
, max(test_date) test_date
, test_date_from
, cash_per_step
from @table
group by test_id,cash_per_step,test_date_from
order by test_id,test_date
Результаты:

See DEMO