Hello
I have a database which holds a main table. The main table holds the first part of all UK postcodes. This has three fields, ID, Postcode Outer and Date added.
The second table holds a further ID, the ID number from the main table, the next part of the postcode which is a numeric and again date added.
The third table holds ID, ID from the second table, last two letters of the postcode and date_added
The final table holds ID, ID from the third table, buildings area, contents area and effective date.
Each postcode is given a rating area to allow us to price insurance based on home location. These rating areas change regularly hence the need for an effective date in the fourth table.
I have a query (thanks to Giacomo who's explanation to someone elses query with some adaption allows me to pull the newest rate from the fourth table. The SQL is as follows:
What I would like to do though is add fields to this query to show information from the first table, second table and third table. However by doing this I then get multiple results from the fourth table showing all results instead of the latest rates.
Please could someone help me understand this or if I have the design wrong any pointers would be gratefully received.
Thanks
I have a database which holds a main table. The main table holds the first part of all UK postcodes. This has three fields, ID, Postcode Outer and Date added.
The second table holds a further ID, the ID number from the main table, the next part of the postcode which is a numeric and again date added.
The third table holds ID, ID from the second table, last two letters of the postcode and date_added
The final table holds ID, ID from the third table, buildings area, contents area and effective date.
Each postcode is given a rating area to allow us to price insurance based on home location. These rating areas change regularly hence the need for an effective date in the fourth table.
I have a query (thanks to Giacomo who's explanation to someone elses query with some adaption allows me to pull the newest rate from the fourth table. The SQL is as follows:
SELECT x.Effective_date, x.Walk_ID, x.Builidngs_Area, x.Contents_Area
FROM tbl_Rating_areas AS x
WHERE (((x.Effective_date)=(select max(effective_date) from tbl_rating_areas where walk_id = x.Walk_ID)));
What I would like to do though is add fields to this query to show information from the first table, second table and third table. However by doing this I then get multiple results from the fourth table showing all results instead of the latest rates.
Please could someone help me understand this or if I have the design wrong any pointers would be gratefully received.
Thanks