Someone help! In creating an inventory system I have been trying to query four fields from multiple tables grouping the records by the serial number (same one occurs multiple times in assignment table) and attempting to get the most recent record for each serial group by using the max function with the date when I do totals. However, I also want the first and last name persons in the table and am forced to choose a total value such as max, min, var... While I do get back the correct serial number and assignment date, I don't always get back the correct first OR last name that corresponds to the serial number. How can I create a query using GROUP BY for serial number, MAX for the date while simultaneously retrieving additional fields for the same record such as first and last name and have both name fields be accurate? Below is a simplified summary example of my query.
SELECT [ASSIGNMENT_SERIAL_NO], [MAX(ASSIGNMENT_DATE_ASSIGNED)], ASSIGNMENT_FIRST_NAME, ASSIGNMENT_LAST_NAME, FROM ASSIGNMENT GROUP BY ASSIGNMENT_SERIAL_NO
First and last name are from different tables than in the query above. However, in this example, pretend they are all from the same table and disregard that I left out some of the syntax such as AS, possible special characters and so forth since I tried to simplify it for this example. I've been working on this one for a couple of days. I've also searched this site and didn't find a solution directly related to my problem. Any help would be greatly appreciated. Thanks.
SELECT [ASSIGNMENT_SERIAL_NO], [MAX(ASSIGNMENT_DATE_ASSIGNED)], ASSIGNMENT_FIRST_NAME, ASSIGNMENT_LAST_NAME, FROM ASSIGNMENT GROUP BY ASSIGNMENT_SERIAL_NO
First and last name are from different tables than in the query above. However, in this example, pretend they are all from the same table and disregard that I left out some of the syntax such as AS, possible special characters and so forth since I tried to simplify it for this example. I've been working on this one for a couple of days. I've also searched this site and didn't find a solution directly related to my problem. Any help would be greatly appreciated. Thanks.