I have a question regarding a database query on unrelated tables.
It is required that VBA isn’t used this time (requirement from my manager), which makes it hard.
My query must return 5 columns of data.
The first 4 columns are directly retrieved from the Output of a previous query, so that is easy.
Query Q_STOP_LOSS:
Year Contr_Pool_ID Contr_Ins_ID COUNTRY Employees STOP_LOSS
2010 Crédit Agricole CIB QUATREM 2 6024
2010 Crédit Agricole CIB QUATREM 2 6024
2010 Amada CO LTD MALAKOFF MEDERIC 4 1320
2010 Amada CO LTD MALAKOFF MEDERIC 4 1320
2010 Amada CO LTD MALAKOFF MEDERIC 4 1320
The last column called “STOP_LOSS” is the problem because the value filled in there should be retrieved from an unrelated table based on a WHERE clause.
It should contain the SL value from another table that does not contain equal fields.
The table is called T_STOP_LOSS and lists intervals.
Table: T_STOP_LOSS
ID LIVES_FROM LIVES_TO NR_COUNTRIES_FROM NR_COUNTRIES_TO SL_VALUE
1 0 999 2 2 39,3
12 0 999 3 3 34,6
23 0 999 4 4 29,6
34 0 999 5 9 25,7
45 0 999 10 100 22,17
46 1000 1499 2 2 31,1
2 1000 1499 3 3 27,4
13 1000 1499 4 4 23,3
24 1000 1499 5 9 20,4
35 1000 1499 10 100 17,5
When the values for “Country” and “Employees” (columns 3 & 4, being the results of previous queries) lie in the interval between respectively “LIVES_FROM/LIVES_TO” AND “NR_COUNTRIES_FROM/NR_COUNTRIES_TO”, then what should be returned needs to be the corresponding SL_Value. I can’t figure it out since there are no corresponding fields between the two tables and I’m not allowed to use VBA this time.
To make it harder, “LIVES_FROM/LIVES_TO” and “NR_COUNTRIES_FROM/NR_COUNTRIES_TO” contain the ID of a related table.
Any idea how I can get add this column to the query without using VBA… ?
I attempted to use the Query tool and also SQL view, but I was unable to achieve a proper result (with VBA it would be a lot easier and I am not the most handy one with Access on its own…).
Let me know when my question is not clear!
How about: