Left Join not working as expected

millhouse123

New member
Local time
Today, 03:43
Joined
Oct 1, 2014
Messages
4
I have a simple nested query that is not working as expected. My inner query returns 102 records but when I run with outer query I only get 96 records. Below is my query, I don't really want to pull the same fields from both tables but I was doing to test. The values that are missing are those that don't exist with the monthenddate 8/31/2014 - a left join should fix that but doesn't seem to be working and I am out of ideas. any help would be much appreicated.

Code:
Select  distinct a.entity, a.gl_account,a.profit_center,[Open Items_1].profit_center,[Open Items_1].gl_account,[Open Items_1].entity
from(
SELECT DISTINCT  [Open Items].entity, [Open Items].gl_account, [Open Items].profit_center
FROM [Open Items] 
)a
left outer JOIN  [Open Items]  AS [Open Items_1] ON
 (a.profit_center = [Open Items_1].profit_center) AND (a.gl_account = [Open Items_1].gl_account) AND (a.entity = [Open Items_1].entity)
Where  ([Open Items_1].MonthEndDate=#8/31/2014#)
 

Users who are viewing this thread

Back
Top Bottom