Tim L
Registered User.
- Local time
- Today, 18:13
- Joined
- Sep 6, 2002
- Messages
- 414
I have a table in which there are four data fields; date 1 ('lowest') to date 4 ('highest'). The purpose of each field is to record when a particular state has been entered. It is possible for the states to occur in the orders as follows:
Apart from the rule that states occur from 1 up and from high to low in sequential order, the newest data could occur in any field. As can be seen, it is possible that not all fields contain dates at any one time (but hey, this is the easy part, I think).
I need to create a query to count the quantity of each field that has been completed but only including the most recent in the count. Currently I count all date entries, so for a table with 6 records in I could end up with a query that produces
State 1: 5
State 2: 4
State 3: 2
State 4: 0
Which, of course, adds up to more than 6 records total. I can assume that there are 5 occurences of state 1, of which 4 also have occurences of state 2 of which 2 also have occurences of state 3, but I cannot determine which was the most recent and it may be the case that for one of the records state 3 was entered but state 2 has been entered again since then.
It is necessary to track when each state occurred, so using a single date field with a state indicator is not appropriate, also there are only 4 possible states; a linked table to record the state changes has been considered but would, in the long run, result in a larger database as more than 4 states could be recorded, plus there's the link field overhead.
Can anyone suggest how I may go about creating a query to get accurate counts?
Tim
1, 2, 3, 4
1, 2, 3, 2, 1
1, 2, 3, 4, 3, 2, 1
1, 2, 1, 2, 3, 2
1, 2, 3, 2, 1
1, 2, 3, 4, 3, 2, 1
1, 2, 1, 2, 3, 2
Apart from the rule that states occur from 1 up and from high to low in sequential order, the newest data could occur in any field. As can be seen, it is possible that not all fields contain dates at any one time (but hey, this is the easy part, I think).
I need to create a query to count the quantity of each field that has been completed but only including the most recent in the count. Currently I count all date entries, so for a table with 6 records in I could end up with a query that produces
State 1: 5
State 2: 4
State 3: 2
State 4: 0
Which, of course, adds up to more than 6 records total. I can assume that there are 5 occurences of state 1, of which 4 also have occurences of state 2 of which 2 also have occurences of state 3, but I cannot determine which was the most recent and it may be the case that for one of the records state 3 was entered but state 2 has been entered again since then.
It is necessary to track when each state occurred, so using a single date field with a state indicator is not appropriate, also there are only 4 possible states; a linked table to record the state changes has been considered but would, in the long run, result in a larger database as more than 4 states could be recorded, plus there's the link field overhead.
Can anyone suggest how I may go about creating a query to get accurate counts?
Tim