What I have deliberately left out
No site layout, no credential scheme, no reader topology, no access-control configuration. The engineering pattern is useful to describe. The security posture of a specific facility is not.
Where the difficulty actually lives
Not in the query. In the fact that a person can have two credentials, that a badge reported lost is sometimes still in use, that contractors exist in one system and not the other, and that every one of those cases needs a defined behaviour rather than a NULL.