I am trying to run a single SELECT statement pulling data from three tables (PERSONAL, EMPLOYEE, SALARY) to return each employee's name, address, start date, etc. and their most recent salary amount. There will be only one personal and employee record for each employee though they will have numerous historical salary records. I figured that if I grouped by SSN (key field across all of the tables) and used the MAX(SALARY.PAYDATE) in the SELECT, I would get data from the most recent (highest paydate) SALARY record. The results seemed to be a mixed bag. All of the records reflect the correct (most recent) pay date values. However, the salary amounts are sometimes correct, but usually not. In some cases, it seems to be a salary amount from earlier in the individual employee's history.
I know that I could do this with a couple of SELECT statement, etc, but I thought I could do this in one step. Will the MAX() function work the way I want or does it only return the correct value for the field to which it has been applied and anything else from that table might or might not be from that record?
Thanks
Bob
I know that I could do this with a couple of SELECT statement, etc, but I thought I could do this in one step. Will the MAX() function work the way I want or does it only return the correct value for the field to which it has been applied and anything else from that table might or might not be from that record?
Thanks
Bob