B
Bob Quintal
You need to use a subquery to first return the max() value relatedHi
I have a Jobs table with Staff ID, Job Rate and Job Date. Staff
start at a rate and their jobs from that day onwards have that
rate. Then they get a raise and this is reflected in their
subsequent jobs and so on.
I need to extract from the above table a result set which has
Staff ID, Max of the their Rates (i.e. current salary of the
staff), First Job's date on that Max Rate (i.e. date of last pay
rise). How can I achieve this using queries?
Thanks
Regards
to the employee ID, then use that to get the other relevand data.
SELECT M.[Staff ID], M.[Job Rate], M.[Job Start Date]
FROM Jobs Alias M
WHERE M.[Job Rate] =
(SELECT max([Job Rate]) as CurrentRate
FROM Jobs Alias S
WHERE M.[Staff ID] = S.[Staff ID])
AND M.[Staff ID] = [S. Job ID]
You can build the subquery first, test it, and then paste the SQL
into the criteria row of the Main Query.
But Is your way the right way? What if an employee gets a pay
decrease? ( it does happen)
Would it not be better to get the most recent Job date and lookup
the salary?