Q:

SQL Compare one Date from multiple rows between two date

I have 2 tables with common identifier column.
Compare the first tab1 to tab2 and need result which the dates not between the tab2
Create  table #tab1(id int, Idvalue int, IDDate date)
insert into #tab1
select 1,1, '2013-06-25' UNION ALL 
select 2,1, '2014-11-28' union all
select 3,1, '2015-12-06' union all
select 4,1, '2013-04-08' union all
select 5,1, '2051-12-12'
Select * from #tab1

Create  table #tab2(Idvalue int, Startdate date, EndDate Date)
insert into #tab2
select 1, '2013-05-01','2013-12-31' UNION ALL 
select 1, '2014-06-01','2050-01-01'

Select * from #tab2

DROP table #tab1
DROP table #tab2

Result:
4   1   2013-04-08
5   1   2051-12-12

A:

Try with left join
select * from tab1 left join tab2 on IDDate between Startdate and enddate
where Idvalue is null

