Experts:
I need some assistance with streamlining a query (or # of queries). Allow me to provide some background first.
The attached database includes two (2) tables:
1. tblCity
2. tblFiscalYear
Background:
- tblCity includes forty (40) example records.
- Ultimately, there are 20 distinct cities (currently 2 each in this example) in field [City]
- For the most part, the value in field [Code] is the same for the cities (e.g., record #2 and #22 both equal Charlotte and B).
- However, in this sample data, there are cities where the codes has changed (e.g., "Chicago"). That is, record #3's [Code] = C while record #23's [Code] = D.
What I want to achieve:
- I want to identify the cities where the code has changed.
- In this case, my Query4 correctly outputs: Austin (A, Z); Chicago (C, D); Houston (H, S).
- Unfortunatly, I currently have to use three (3) "Helper Queries" in order to get the output in Query 4:
-- Query1 serves as input to Query2
-- Query2 serves as input to Query3
-- Query3 serves as input to Query4
Existing Problem: I use too many "helper" queries and I need to mitigate the # of required queries to get to the desired output (shown in Query4).
Goal: How should I modify the query process so that I don't need the 3 helper queries? Ideally, I would have a single query (but using one helper query -- if required -- would be ok, too).
Note #1: Next year, I will add the same 20 cities to the data set. So, when using a GROUP BY query, the count will not always be >1... next year, it may be greater than >2.
Note #2: If set city data (e.g., Fiscal Year 19) includes a city that was NOT listed in FY18, I probably also want to output this city as well. However, maybe I should use a separate query for any cities where I don't have a 1:1 match between the fiscal year.
Thank you,
EEH