Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:50:54+00:00 2026-06-11T18:50:54+00:00

Update at the bottom. I am trying to do a self outer join that,

  • 0

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 the latest record. This is my sql code:

SELECT A.[CR#], A.REGIS_STATUSDATE, B.REGIS_STATUSDATE
FROM CR_ADMIN_REGIS_STATUS A LEFT OUTER JOIN CR_ADMIN_REGIS_STATUS B
ON A.[CR#]=B.[CR#] AND A.REGIS_STATUSDATE < B.REGIS_STATUSDATE

My issue is this is that when, for a given [CR#], A.REGIS_STATUSDATE is a maximum (and therefore the B.REGIS_STATUSDATE cannot be greater than it), that row is not included in my result.

For example, if CR_ADMIN_REGIS_STATUS looks like this:

CR#   REGIS_STATUSDATE
1     5/1/12
1     5/2/12
1     5/3/12
2     5/1/12
2     5/2/12

I expect the result of my query to be

CR#   A.REGIS_STATUSDATE B.REGIS_STATUSDATE
1     5/1/12             5/2/12
1     5/1/12             5/3/12
1     5/2/12             5/3/12
1     5/3/12             NULL
2     5/1/12             5/2/12
2     5/2/12             NULL

Instead I get this:

CR#   A.REGIS_STATUSDATE B.REGIS_STATUSDATE
1     5/1/12             5/2/12
1     5/1/12             5/3/12
1     5/2/12             5/3/12
2     5/1/12             5/2/12

Given that my query is a LEFT OUTER JOIN, and I have no WHERE clause, I expect all rows from my original table to be in the result, but this is not the case. What am I missing here?

Edit: This is in Access 2007

Update: I decided to see what would happen if I copied sections of the table CR_ADMIN_REGIS_STATUS into a separate table and ran my query against that. Even when I had just straight up copied the entire table into the new one (manually) the query worked! This was only the case when actually copying and pasting though, when I would SELECT * INTO another table the problem would persist.
Eventually I discovered that if I ran the query against

SELECT *
FROM CR_ADMIN_REGIS_STATUS
UNION ALL SELECT TOP 1 * 
FROM CR_ADMIN_REGIS_STATUS;

rather than CR_ADMIN_REGIS_STATUS itself my query returned the desired result. Weird. I also had a similar query against a similar table which worked from the start, so it seems this was an issue limited to this one table.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:50:55+00:00Added an answer on June 11, 2026 at 6:50 pm

    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
          ) ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

update: at bottom I am trying to get a layout working where the body
UPDATE - New code at the bottom I'm trying to figure out how to
I am trying to Update Schema on SQL Server CE 3.5 using Active Record
8/5/11: Update near bottom of post I'm trying to call my WCF web service
UPDATE: The effects work fine. The last thing that remains is trying to slide
(Please see update at bottom) I've looked at dozens of questions and haven't been
Update: See the bottom of this question for a C# workaround. Hi there, Consider
UPDATE AT THE BOTTOM Maybe somebody could help with this... been struggling with it
Update Solution Found See Bottom of post if interested Seems simple enough and for
UPDATE: First problem solved, second one described at the bottom of this post. UPDATE2:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.