J
J Welsby
I have two tables. One that contains a number of sequential years
(tblMasterYears) and one that contains some simulated data (tblSimData).
Tables with field names and example data as follows:
tblMasterYears:
Year
1
2
3
4
5
6
7
8
9
10
tblSimData:
Year Premium Loss Result
2 100 25 75
7 100 125 -25
9 100 200 -100
This database is an insurance model that simulates loss data. Depending on
expected frequency (ie the number of losses) and expected severity (ie the
size of each loss) the tblSimData will have a varying number of simulated
loss records produced. In practice, the database is run with 500k years of
simulation such that tblMasterYears will have 500k year records and
tblSimData will have approximately 75k loss records.
What I would like is to generate a SQL string that can provide a user form
with data for all years. Example from data above:
Year Premium Loss Result
1 100 0 100
2 100 25 75
3 100 0 100
4 100 0 100
5 100 0 100
6 100 125 -25
7 100 0 100
8 100 0 100
9 100 200 -100
10 100 0 100
When there are no loss records in tblSimData (ie years 1, 3-5, 7-8 and 10)
the simulated result is always the same (ie same premium of 100, loss of 0
and result of 100).
Currently, the database runs and the tblSimData contains all 500k records
(they are all created in SQL) which is obviously very redundant and
inefficient.
I have created a simple standalone database with a subquery to UNION two
query strings together but it completely chokes on only about 50K simulation
years. In doing so, I created a record in the tblSimData table as follows:
Year Premium Loss Result
0 100 0 100
which is used to provide the data for any years which are 'loss free' (ie
loss amount is 0 and is thus not in the tblSimData).
Anyone have any ideas on how this can be achieved? Thanks in advance.
James Welsby
(tblMasterYears) and one that contains some simulated data (tblSimData).
Tables with field names and example data as follows:
tblMasterYears:
Year
1
2
3
4
5
6
7
8
9
10
tblSimData:
Year Premium Loss Result
2 100 25 75
7 100 125 -25
9 100 200 -100
This database is an insurance model that simulates loss data. Depending on
expected frequency (ie the number of losses) and expected severity (ie the
size of each loss) the tblSimData will have a varying number of simulated
loss records produced. In practice, the database is run with 500k years of
simulation such that tblMasterYears will have 500k year records and
tblSimData will have approximately 75k loss records.
What I would like is to generate a SQL string that can provide a user form
with data for all years. Example from data above:
Year Premium Loss Result
1 100 0 100
2 100 25 75
3 100 0 100
4 100 0 100
5 100 0 100
6 100 125 -25
7 100 0 100
8 100 0 100
9 100 200 -100
10 100 0 100
When there are no loss records in tblSimData (ie years 1, 3-5, 7-8 and 10)
the simulated result is always the same (ie same premium of 100, loss of 0
and result of 100).
Currently, the database runs and the tblSimData contains all 500k records
(they are all created in SQL) which is obviously very redundant and
inefficient.
I have created a simple standalone database with a subquery to UNION two
query strings together but it completely chokes on only about 50K simulation
years. In doing so, I created a record in the tblSimData table as follows:
Year Premium Loss Result
0 100 0 100
which is used to provide the data for any years which are 'loss free' (ie
loss amount is 0 and is thus not in the tblSimData).
Anyone have any ideas on how this can be achieved? Thanks in advance.
James Welsby