select a.*,b.*
from a left join b
on a.日期>=b.起始日期
and a.日期<=b.终止日期

解决方案 »

  1.   

    select a.代码,b.起始日期,b.终止日期 from a join b 
    on a.日期>=b.起始日期 and a.日期<=b.终止日期      --代码重复,无法继续
      

  2.   

    select B.起始日期,B.终止日期 from A,B where A.日期>B.起始日期 and A.日期<=B.终止日期
      

  3.   

    --我上面做错了,现在改成这样:
    select B.起始日期,B.终止日期 from A,B where A.日期 between B.起始日期 and B.终止日期 group by B.起始日期,B.终止日期--得到的结果:2000-01-01 00:00:00.000     2001-12-31 00:00:00.000
    2002-01-01 00:00:00.000     2002-12-31 00:00:00.000
    2003-01-01 00:00:00.000     2003-08-31 00:00:00.000