R
Rolls
I encounter frequent situations where I want to join a date field in one
table with a date that lies between a beginning date field and an ending
date field in a second table. I want the query result to include several
other fields from each table such that each record in the first table
matches only one record in the second table.
Examples include:
A daily calculation of the day's closing stock price with a 12-month target
share price picked from another table. The target may change between once
every several years to several times per year.
Using Access to price inventory where a history of multiple price changes
must be retained, in order to charge or credit customers based on an invoice
date that falls into a range of dates that reflect inflationary repricing.
Etc.
I know how to do this with sequential record processing using a loop that
finds the correct record in the second table and then copies all needed
fields and calculations from both tables into a new table. But I wondered
if I had missed something. Can this be accomplished via a join with SQL?
If so, what is a sample SQL statement that does this?
I.e., "Table1.Date1 is 'GE' Table2.Date2 and .LE. Table2.Date3".
table with a date that lies between a beginning date field and an ending
date field in a second table. I want the query result to include several
other fields from each table such that each record in the first table
matches only one record in the second table.
Examples include:
A daily calculation of the day's closing stock price with a 12-month target
share price picked from another table. The target may change between once
every several years to several times per year.
Using Access to price inventory where a history of multiple price changes
must be retained, in order to charge or credit customers based on an invoice
date that falls into a range of dates that reflect inflationary repricing.
Etc.
I know how to do this with sequential record processing using a loop that
finds the correct record in the second table and then copies all needed
fields and calculations from both tables into a new table. But I wondered
if I had missed something. Can this be accomplished via a join with SQL?
If so, what is a sample SQL statement that does this?
I.e., "Table1.Date1 is 'GE' Table2.Date2 and .LE. Table2.Date3".