我对以下问题感到困惑。我正在执行左外部联接,它返回的行数比根本没有联接要多。
select COUNT(*) specimen_id from QuickLabDump a
left outer join PracticeandPhysician c
on (a.[Requesting Physician]=c.doctorfirstname+' '+c.DOCTORLASTNAME
and a.[practice code]=c.practicecode)
where
DATEPART(mm, [DATE entered]) =12
and
DATEPART(yy, [DATE entered])=2011
产量 108387
鉴于
select COUNT(*) specimen_id from QuickLabDump a
where
DATEPART(mm, [DATE entered]) =12
and
DATEPART(yy, [DATE entered])=2011
产量 108357
他们不应该返回相同数量的行吗?
最佳答案
第二个表在主表中每行可能有更多行,这就是重点
关于sql - 左外部连接比没有连接返回更多的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8762631/