设置
create table #history (
adddttm date,
number int
)
insert into #history values ('2013-01-01 08:56:00.000',1);
insert into #history values ('2013-01-01 08:56:00.000',2);
insert into #history values ('2013-02-13 08:56:00.000',2);
insert into #history values ('2013-02-13 08:56:00.000',3);
询问
select *
from #history new
left join #history old
on new.number = old.number
where new.adddttm = '2013-02-13 08:56:00.000'
and old.adddttm = '2013-01-01 08:56:00.000'
我希望以下查询返回:
----------|-|----------|-
2013-02-13|2|2013-01-01|2
2013-02-13|3|null |null
但我从来没有得到第二排。为什么这个左连接会跳过丢失的行?