If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
complex query to pull unique values
I have an inspection table to keep track of rooms in various buildings.
These rooms are shared with different supervisors. One inspection of a location would result in x # of inspection records. If the room was shared by 3 supervisors, the same inspection would generate 3 inspection records. Comment field on each record would be different according to the supervisor, were their employees following protocol, safety issues etc. Since there are so many fields, trying to pull unique values is difficult, so I made a new field in the query which concatenates SupervisorID, Bldg & Room to make a single unique value. This part is fine. I can pull unique Supervisor/location records with no problem. However, I only want the most recent inspection. I set the Totals part of the concatenated field to "Group By" and the rest to "First". Even though the dates are sorted as descending in the query, it pulls the First date from the original table, which by default is sorted ascending. So essentially I get the most outdated inspection, not the most recent. I've tried a two query approach. Make the first query, just sort the dates descending. Then make a new query based on the first, with the concatenated fields and so on. It gives the same result. I've tried putting my date field as the first column in the query. It gives the same result. How can I solve this date sorting issue? |
Thread Tools | |
Display Modes | |
|
|