S
Stephen
I am trying to generate a query that does the following:
I have a database that lists my 1000 clients
Each client has retail location in various states in the United States
I am trying to create a form that would list the following:
1) a specific clientID would be passed to the query
2) the result set would always have 50 records; each state would be listed
as a separate record
3) Each of the 50 records would show the state name, and the number of
locations for the chosen client in that state.
Example:
Alaska 2
Arizona 1
Arkansas 0
California 3
Colorado 0
.....
Here are the tables I am using:
tblStates (StateID, StateName)
tblClientLocations (ClientID, StateID, LocationCity)
tblClients (ClientID, ClientName)
We are dealing with 1000's of clients, so we are trying to pass the query a
ClientID rather than getting a full list of records for all clients (50,000+
records) of which the form then filters the query.
I have considered using a union query (but couldn't get it to work) where I
union:
1) the list of states in which the client has locations
2) the list of states in which the client has no locations
Can anyone help with this query? I believe it is probably not that
complicated, but I am so deep in the weeds that I cannot look at it clearly.
NOTE: This is actually being built in SQL with views and in-line
fuunctions, but the query should translate from Access to SQL.
-Stephen
I have a database that lists my 1000 clients
Each client has retail location in various states in the United States
I am trying to create a form that would list the following:
1) a specific clientID would be passed to the query
2) the result set would always have 50 records; each state would be listed
as a separate record
3) Each of the 50 records would show the state name, and the number of
locations for the chosen client in that state.
Example:
Alaska 2
Arizona 1
Arkansas 0
California 3
Colorado 0
.....
Here are the tables I am using:
tblStates (StateID, StateName)
tblClientLocations (ClientID, StateID, LocationCity)
tblClients (ClientID, ClientName)
We are dealing with 1000's of clients, so we are trying to pass the query a
ClientID rather than getting a full list of records for all clients (50,000+
records) of which the form then filters the query.
I have considered using a union query (but couldn't get it to work) where I
union:
1) the list of states in which the client has locations
2) the list of states in which the client has no locations
Can anyone help with this query? I believe it is probably not that
complicated, but I am so deep in the weeds that I cannot look at it clearly.
NOTE: This is actually being built in SQL with views and in-line
fuunctions, but the query should translate from Access to SQL.
-Stephen