What are the expected Codes for the 3 records in tblRates?
***
An income level of 5000 could be Code D or C.
An income level of 2500 could be Code B or A.
An income level of 4000 could be Code C or B.
Does Family size come into play?
tblRates R_ID #3 has a family size of 2, but tblCodes does not have a Family size of 2.
This is the query I came up with:
Code:
SELECT tblRates.R_ID, tblRates.Fam_Size, tblRates.Income_level,
(SELECT TOP 1 tblCodes.Code FROM tblCodes WHERE tblRates.Income_level>=[tblCodes].[Min_Income] And tblRates.Income_level < [tblCodes].[Max_Income];) AS Code
FROM tblRates;
Note the "TOP 1" in the subquery. (see the the *** above)
Note the Family size is not taken into account.
R_ID |
Fam_Size |
Income_level |
Code |
1 |
1 |
5000 |
D |
2 |
1 |
2500 |
B |
3 |
2 |
4000 |
C |