Hi, How I can get the exptected output. I wan to join both table.
I want to get correct the actualtravaldate. I have dates in #travalplan. These dates should match with the dates of actualtravaldate, if dates doesn't match then take the nearest ahead data. Please help on this.
create table #travalplan (name char(20),traveldate datetime)
insert into #travalplan values ('Yousuf','2014-05-01')
insert into #travalplan values ('Hira','2014-06-20')
create table #traval (plan_code numeric,actualtraveldate datetime)
insert into #traval values (200,'2014-04-20')
insert into #traval values (300,'2014-04-30')
insert into #traval values (301,'2014-05-15')
insert into #traval values (302,'2014-06-15')
insert into #traval values (303,'2014-06-23')
--Exppected Output
name traveldate actualtraveldate
Yousuf,2014-05-01 2014-05-15
Hira,2014-06-01 2014-06-23