Update at the bottom.
I am trying to do a self outer join that, for each record, returns it and all other records occuring later than it, or NULL if it itself is t
You are not missing anything. If this happens, it's a bug.
The engine used by MS-Access has several bugs. I've seen similar, inavlid behaviour in joins that had "complex" ON
conditions. See another SO question where Access gives buggy results: Why does my left join in Access have fewer rows than the left table?
You can try the query with identical data in SQL-Server, Oracle, Postgres, even MySQL and you will get the correct, expected results.
As a workaround, you can try rewriting the query with a UNION
, but one can never be sure about the correctness:
SELECT A.[CR#], A.REGIS_STATUSDATE, B.REGIS_STATUSDATE
FROM CR_ADMIN_REGIS_STATUS A
INNER JOIN CR_ADMIN_REGIS_STATUS B
ON A.[CR#]=B.[CR#]
AND A.REGIS_STATUSDATE < B.REGIS_STATUSDATE
UNION ALL
SELECT A.[CR#], A.REGIS_STATUSDATE, NULL
FROM CR_ADMIN_REGIS_STATUS A
WHERE NOT EXISTS
( SELECT *
FROM CR_ADMIN_REGIS_STATUS B
WHERE A.[CR#]=B.[CR#]
AND A.REGIS_STATUSDATE < B.REGIS_STATUSDATE
) ;