我正在尝试在访问中编写一个SQL查询,比较两个表。查询是将一个表中的最新数据与另一表中的旧数据进行比较。例如;
表1(新数据)
/------------------------------------------------------------------------\
| ID | Status | ProductID | Request Date | ReqReviewed | Closed Date |
|----+------------+-----------+--------------+-------------+-------------|
| 1A | Successful | 0001 | 09/10/2000 | Yes | 09/20/2000 |
| 1A | Pending | 0002 | 09/10/2000 | Yes | |
| 2C | Successful | 0001 | 07/20/2001 | Yes | 07/29/2001 |
| 3A | Pending | 0003 | 03/01/2002 | Yes | |
| 3A | Pending | 0002 | 03/01/2002 | Yes | |
| 4A | Pending | 0001 | 04/09/2002 | | |
| 5B | Successful | 0005 | 04/08/2001 | Yes | 05/20/2001 |
| 6F | Created | 0001 | | | |
\------------------------------------------------------------------------/
表2(旧数据)
/------------------------------------------------------------------------\
| ID | Status | ProductID | Request Date | ReqReviewed | Closed Date |
|----+------------+-----------+--------------+-------------+-------------|
| 1A | Pending | 0001 | 09/10/2000 | No | |
| 1A | Pending | 0002 | 09/10/2000 | No | |
| 2C | Successful | 0001 | 07/20/2001 | Yes | 07/29/2001 |
| 3A | Returned | 0003 | 03/01/2002 | Yes | |
| 3A | Pending | 0002 | 03/01/2002 | No | |
| 4A | Created | 0001 | | | |
| 5B | Successful | 0005 | 04/08/2001 | Yes | 05/20/2001 |
\------------------------------------------------------------------------/
*** ID和ProductID将保持不变,并且ID可以包含具有不同ID的重复项,反之亦然。其他字段每天都可以更改。
我试图仅获取从前一天(表2)开始更改的记录(表1),特别是可以在前一天为空然后在第二天填充的字段(请求日期,ReqReviewed等) 。任何帮助将不胜感激!