IF OBJECT_ID('tempdb..#testtable') IS NOT NULL DROP TABLE #testtable
create table #testtable (number nvarchar(255), spac money, dateR date)
insert into #testtable
(number, spac, dateR)
values
(1,10,'20140505'),
(1,11,'20141212'),
(2,50,'20160505'),
(2,40,'20160508')
IF OBJECT_ID('tempdb..#testtableRNK') IS NOT NULL DROP TABLE #testtableRNK
select * ,
rank() over (partition by Number order by dateR desc) as RNK
into #testtableRNK
from #testtable
select * from #testtableRNK r1
inner join #testtableRNK r2 ON r1.number= r2.number and r2.RNK=(r1.RNK+1) and r1.RNK=1 and r2.spac< r1.spac