I am trying to get results that have all of the values from the Groups table and any matching values from the CitDetail table. The first procedure skips the Groups entries if there are no CitDetal entries. Is this because of the Inner Join on the third table makes the whole procedure an Inner Join? I can get the results I want using the second procedure listed below. Is there a better way to do this? The code has been simplified to make it easier to read.
Auguy
Sylvania/Toledo Ohio
Code:
Select G.RptCitation, Count(D.Section)
FROM Groups G
LEFT OUTER JOIN CitDetail D On G.OurClass = D.Section And D.CitNo Like 'SC%' And D.IssueDt >= '20120520'
INNER JOIN CrossRef as CR On D.IncdNo = CR.IncdNo
Group by G.Citation
Order by G.Citation
Code:
Select G.Citation, Count(S.Section)
FROM Groups G
LEFT OUTER JOIN (
Select D.Section
FROM CitDetail D
INNER JOIN CrossRef as CR On D.IncdNo = CR.IncdNo
Where D.CitNo Like 'SC%' And D.IssueDt >= '20120101') as S
On G.OurClass = S.Section
Group by G.Citation
Order by G.Citation
Auguy
Sylvania/Toledo Ohio