I've heard of cross apply, but have to date never had a time I thought I needed to use it. Below is a sample of something I've done more then a few times, and then the same using cross apply.
edit* Can someone explain what the difference (if any) there is between the join example and the cross apply example for this situation
DROP TABLE IF EXISTS #test
/*creating test table and inserting test rows*/
create table #test (id char(1), val int, dt date)
insert into #test values ('a',1,'2022/1/6')
insert into #test values ('a',4,'2022/1/7')
insert into #test values ('a',7,'2022/1/8')
insert into #test values ('a',5,'2022/1/9')
insert into #test values ('a',3,'2022/1/10')
insert into #test values ('a',1,'2022/1/11')
insert into #test values ('b',1,'2022/1/6')
insert into #test values ('b',4,'2022/1/7')
insert into #test values ('b',6,'2022/1/8')
insert into #test values ('b',8,'2022/1/9')
insert into #test values ('b',3,'2022/1/10')
insert into #test values ('b',5,'2022/1/11')
insert into #test values ('c',1,'2022/1/6')
insert into #test values ('c',4,'2022/1/7')
insert into #test values ('c',6,'2022/1/8')
insert into #test values ('c',8,'2022/1/9')
insert into #test values ('c',3,'2022/1/10')
insert into #test values ('c',5,'2022/1/11')
-- this is the way I've been accomplishing this task
SELECT t.id
,t.val
,t.dt
FROM #test t
JOIN (
SELECT max(dt) max_dt
,id
FROM #test
GROUP BY id
) maxt ON maxt.max_dt = t.dt
AND maxt.id = t.id
ORDER BY t.id
--this gives the same results but using cross apply
select t1.*
from #test t1
cross apply
(
select max(t2.dt) dt, id
from #test t2 where t2.id = t1.id
group by id
) cx
where cx.dt = t1.dt