I am working with a db that tracks revisions to a book. Revisions are captured in the Revisions table with a timestamp. I need to show in a form which Book Edition the revision affected (which is always the next published edition).
The 2 tables with data that look like this:
dimBookEdition
tblRevisionLog
The desired output
This query will give me the list, but I cannot figure out how to get the MAX DiffPubDate for each group of revision ID's or Row 1.
Thank you for any help.
You don't know what you don't know...
The 2 tables with data that look like this:
dimBookEdition
Code:
pk_BookEditionID BookEdition EditionPubDate
1 1st Edition 3/1/1997
2 2nd Edition 1/15/2000
3 3rd Edition 11/3/2003
4 4th Edition 1/1/2008
5 5th Edition 11/28/2012
6 6th Edition 1/29/2018
7 7th Edition 12/31/2023
tblRevisionLog
Code:
pk_RevisionLogID DateTimeCreated
36 01/16/1996
37 02/10/1997
38 12/16/1999
39 06/26/2005
40 04/25/2009
41 12/06/2018
The desired output
Code:
pk_RevisionLogID DateTimeCreated BookEdition
36 01/16/1996 1st Edition
37 02/10/1997 1st Edition
38 12/16/1999 2nd Edition
39 06/26/2005 4th Edition
40 04/25/2009 5th Edition
41 12/06/2018 7th Edition
This query will give me the list, but I cannot figure out how to get the MAX DiffPubDate for each group of revision ID's or Row 1.
SQL:
SELECT pk_RevisionLogID, DateTimeCreated, Edition, DateDiff("d",[dimBookEdition].[EditionPubDate],[tblRevisionLog].[DateTimeCreated]) AS DiffPubDate
FROM dimBookEdition, tblRevisionLog
ORDER BY pk_RevisionLogID, DateDiff("d",[dimBookEdition].[EditionPubDate],[tblRevisionLog].[DateTimeCreated]) DESC
Thank you for any help.
You don't know what you don't know...