select *
from
(
select *,row_number() over (partition by id order by dte desc) as seq
from tbla a
join cte b
on a.id = b.id
and a.dte = b.dte
and b.amount >0
)t
where seq=1
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/