I am trying to join two tables in a bit of an odd way. My tables are:
tblSeg:
RankID | SegAbbrev | LowerLimit | UpperLimit
1 | A | 6 | 100
2 | B | 3 | 5
3 | C | 0 | 2
and
tblX
RecID | Perc | CountOfID | CountOfStar
1 | 50 | 2 | 1
2 | 33 | 9 | 3
3 | 20 | 5 | 1
4 | 0 | 7 | 0
I need to find which SegAbbrev (or RankID) is appropriate to which RecID. This is worked out depending upon tblX.CountOfID being between the values of tblSeg.LowerLimit and tblSeg.UpperLimit
For instance I should get the result:
RecID | RankID | SegAbbrev
1 | 3 | C
2 | 1 | A
3 | 2 | B
4 | 1 | A
That is not quite it though. If tblX.Perc is greater than another variable lets call it varPerc then SegAbbrev for that record should be AAA and RankID should be 0. So the final result should actually be:
for varPerc=40
RecID | RankID | SegAbbrev
1 | 0 | AAA
2 | 1 | A
3 | 2 | B
4 | 1 | A
A little different from the usual type of join!
I am really struggling with this so if anyone can offer any ideas...
%-)
tblSeg:
RankID | SegAbbrev | LowerLimit | UpperLimit
1 | A | 6 | 100
2 | B | 3 | 5
3 | C | 0 | 2
and
tblX
RecID | Perc | CountOfID | CountOfStar
1 | 50 | 2 | 1
2 | 33 | 9 | 3
3 | 20 | 5 | 1
4 | 0 | 7 | 0
I need to find which SegAbbrev (or RankID) is appropriate to which RecID. This is worked out depending upon tblX.CountOfID being between the values of tblSeg.LowerLimit and tblSeg.UpperLimit
For instance I should get the result:
RecID | RankID | SegAbbrev
1 | 3 | C
2 | 1 | A
3 | 2 | B
4 | 1 | A
That is not quite it though. If tblX.Perc is greater than another variable lets call it varPerc then SegAbbrev for that record should be AAA and RankID should be 0. So the final result should actually be:
for varPerc=40
RecID | RankID | SegAbbrev
1 | 0 | AAA
2 | 1 | A
3 | 2 | B
4 | 1 | A
A little different from the usual type of join!
I am really struggling with this so if anyone can offer any ideas...
%-)