Это должно быть близко к тому, что вы ищете
select r.id, r.td, (
select top 1 c.cost from cost c
where c.id = r.id
and datediff(day, CAST('01-' + c.td AS datetime), r.td) >= 0
order by CAST('01-' + c.td AS datetime) desc
) as cost
from rev r
Пример сценария:
declare @REV table (id int, trandate datetime)
insert into @REV (id, trandate) values (101, '3/5/2018')
insert into @REV (id, trandate) values (101, '3/24/2018')
insert into @REV (id, trandate) values (101, '4/10/2018')
insert into @REV (id, trandate) values (101, '5/30/2018')
insert into @REV (id, trandate) values (101, '6/25/2018')
insert into @REV (id, trandate) values (102, '1/1/2019')
insert into @REV (id, trandate) values (102, '2/4/2019')
insert into @REV (id, trandate) values (102, '2/11/2019')
insert into @REV (id, trandate) values (103, '2/17/2019')
insert into @REV (id, trandate) values (103, '2/25/2019')
insert into @REV (id, trandate) values (103, '3/24/2019')
insert into @REV (id, trandate) values (103, '3/30/2019')
declare @COST table (id int, pcr varchar(20), cost float)
insert into @COST (id, pcr, cost) values (101, 'Jan-18', 16.8)
insert into @COST (id, pcr, cost) values (101, 'May-18', 7.6)
insert into @COST (id, pcr, cost) values (101, 'Jun-18', 14.3)
insert into @COST (id, pcr, cost) values (101, 'Jul-18', 301.88)
insert into @COST (id, pcr, cost) values (101, 'Aug-18', 6.62)
insert into @COST (id, pcr, cost) values (101, 'Nov-18', 0.01)
insert into @COST (id, pcr, cost) values (102, 'Dec-18', 6.62)
insert into @COST (id, pcr, cost) values (102, 'May-18', 47.95)
insert into @COST (id, pcr, cost) values (102, 'Jun-18', 79.8)
insert into @COST (id, pcr, cost) values (102, 'Jul-18', 3.49)
insert into @COST (id, pcr, cost) values (102, 'Jan-19', 30.11)
insert into @COST (id, pcr, cost) values (103, 'Mar-19', 102.11)
select r.id, r.trandate, (
select top 1 c.cost from @cost c
where c.id = r.id
and datediff(day, CAST('01-' + c.pcr AS datetime), r.trandate) >= 0
order by CAST('01-' + c.pcr AS datetime) desc
) as cost
from @rev r
РЕЗУЛЬТАТЫ:
101 2018-03-05 16,8
101 2018-03-24 16,8
101 2018-04-10 16,8
101 2018-05-30 7,6
101 2018-06-2514,3
102 2019-01-01 30,11
102 2019-02-04 30,11
102 2019-02-11 30,11
103 2019-02-17 NULL
103 2019-02-25 NULL
103 2019-03-24 102.11
103 2019-03-30 102.11