I have a point feature layer containing information about water monitoring locations. This includes a unique location ID, upper and lower limits for the recorded values and (what I want to be) the current value at that location. (Table 1)
Table 1:
| Gid | Location_ID | Upper_Limit_m | Lower_Limit_m | Current_Value_m |
| 1 | GW 1 | 880 | 850 | |
| 2 | GW 2 | 886 | 856 | |
| 3 | GW 3 | 884 | 854 | |
I also have a table that contains a history of recorded values at those locations listed above. (Table 2)
Table 2:
| Location_ID | Date | Recorded_Value |
GW 1 | 01/06/2021 | 867.3 |
GW 2 | 01/06/2021 | 894.1 |
GW 3 | 01/06/2021 | 843.9 |
GW 1 | 05/06/2021 | 862.4 |
I am able to create a relationship between these two tables using the Location_ID as the Primary Key, using a one to many cardinality.
What I am trying to achieve is to "join" the most recent value in the Recorded_Value column of Table 2 into the Current_Value column in Table 1 for each unique monitoring location (Location_ID). Furthermore, I need to ensure that the Recorded_Value (from Table 2) is within the upper and lower limits (from table 1).
I'm thinking that I might be able to use a definition query (specifically using SQL) to achieve this.
Is this possible? If so, what would be the syntax to use a value from a related table in a definition query? Or is there an alternative way that I can achieve this?