That DOES seem to be what I need but I'm continually pooching the syntax because obviously I'm not very SQL fluent (I'm using the QBE almost exclusively) but I'm learning, hence why i'm here
This is the query that pulls the core data I need for the UPCOMING drives that I need to link back to the historic drives:
Code:
SELECT DriveInfoSource.DriveID, DriveDates.WeekdayName, CInt([dbo_Accounts]![AccountID]) AS AcctID, DriveInfoSource.MobileOrCenter, DriveInfoSource.State, DriveInfoSource.DriveDate, DriveInfoSource.DriveName, DriveInfoSource.DriveStatus, DriveStaffing.SumOfStaffRequested AS StaffRequested, UnitsCollected.ProductsProjected, UnitsCollected.RBCProjected, DriveInfoSource.Center INTO KatieDrives
FROM (((dbo_Accounts RIGHT JOIN (DriveInfoSource LEFT JOIN dbo_DriveMaster ON DriveInfoSource.DriveID = dbo_DriveMaster.DriveID) ON dbo_Accounts.AccountID = dbo_DriveMaster.AccountID) LEFT JOIN DriveStaffing ON dbo_DriveMaster.DriveID = DriveStaffing.DriveID) LEFT JOIN UnitsCollected ON DriveInfoSource.DriveID = UnitsCollected.DriveID) LEFT JOIN DriveDates ON DriveInfoSource.DriveID = DriveDates.DriveID
WHERE (((DriveDates.WeekdayName)="Saturday") AND ((DriveInfoSource.MobileOrCenter)="Mobile") AND ((DriveInfoSource.State)="IL") AND ((DriveInfoSource.DriveDate)>=#1/1/2019#))
ORDER BY DriveInfoSource.DriveDate;
It SEEMS like something like this should kick back the next three prior DriveIDs, but I keep getting syntax errors OR a blank query returned:
Code:
SELECT TOP 3 dbo_DriveMaster.DriveID
FROM KatieDrives LEFT JOIN dbo_DriveMaster ON KatieDrives.DriveID = dbo_DriveMaster.DriveID
WHERE KatieDrives.DriveDate < DriveMaster.DriveDate;