Select Distinct a.flightNo,'','',a.citypair,a.createdate,a.flightNo+'/'+a.citypair+'/'+a.createdate,b.flightNO from hisIBEdata..his_actualflight_201604 as a left join aTemp as b on a.flightNO=b.flightNO and a.createdate=b.createdate where a.createdate='2016-04-14' and b.flightNO is not null
Select Distinct a.flightNo,'','',a.citypair,a.createdate,a.flightNo+'/'+a.citypair+'/'+a.createdate,b.flightNO from hisIBEdata..his_actualflight_201604 as a left join aTemp as b on a.flightNO=b.flightNO where a.createdate='2016-04-14' and b.flightNO is not null and b.createdate='2016-04-14'
select Distinct flightNo,'','',citypair,createdate,flightNo+'/'+citypair+'/'+createdate from hisIBEdata..his_actualflight_201604 where createdate='2016-04-16' and flightNO in(select flightNO from aTemp where createdate='2016-04-16')