Is there a way to join two tables, in such a way that values from one table can be properly associated with another, when one of the fields in a join will not match all the time?
Here's my scenario:
I have 2 tables, one has account information, the other has rate information.
The account table is updated each month after the billing cycle and has information on a customers account. An example is:
The rate table is only updated when the rates change. An example of the table is:
I would like to figure out a way to join the 2 tables, so that the rate that was in effect at the time of the bill is pulled in. But, I can't directly join the EffectiveDate with the BillDate, since I don't have entries for 2/1/04 and 3/1/04. Is there a way to join these two tables so that the rate will be pulled in when the BillDate is between the EffectiveDates?
Something like this:
Thanks for any help you have!!!
Here's my scenario:
I have 2 tables, one has account information, the other has rate information.
The account table is updated each month after the billing cycle and has information on a customers account. An example is:
Code:
AccNumber UsageType BillDate
123 1 2/1/04
123 1 3/1/04
123 1 4/1/04
123 1 5/1/04
234 2 2/1/04
Code:
UsageType EffectiveDate Rate
1 1/1/04 1.00
1 4/1/04 1.50
2 1/1/04 0.75
2 4/1/04 1.00
Something like this:
Code:
AccNumber UsageType BillDate Rate
123 1 2/1/04 1.00
123 1 3/1/04 1.00
123 1 4/1/04 1.50
123 1 5/1/04 1.50
234 2 2/1/04 0.75