我创建了名为temp_table的临时表,记录为
FromDate ToDate
2011-01-01 00:00:00.000 | 2012-08-16 17:26:44.827
2012-08-16 17:29:06.980 | 2115-01-23 16:29:46.443
我把声明放在
之间select *
from payment p
inner join temp_table t
on t.FromDate >= p.CreatedDate
or t.toDate <= p.CreatedDate
where createddate between temp_tbl.FromDate and temp_tbl.ToDate
但它依赖于1行语句,我希望两个语句都可以调用。
答案 0 :(得分:0)
使用Between
操作加入表On
条件。试试这个。
select *
from payment p
inner join temp_table
on p.CreatedDate between
temp_tbl.FromDate and temp_tbl.ToDate