sql - Access 2010: JOIN tables and return the most recent record -


I am trying to figure out how to get the right results from the following.

I am trying to create an access query that takes relevant staffing rates from calculating costs for employees from timesheet data. The following time is an example of the data:

  ID EmpNo Period_Month Period_Year CostCode Workstage Line_Hours 14 11486 3 2014 C10798 000 20.00 15 11,486 3 2014 C10657 000 21.50 16 11,486 3 2014 C11112 000 10.00  

For this employee, the rates can be set during different times such as:

  EmpNo Period_Month Period_Year Rate 11486 1 2014 10,00 11486 3 2014 12,00 11486 6 2014 15,00 I want to know how I can join two tables to calculate the cost (hour * rate) and only right Can choose rate A rate is affected by the period that it gets stamped and till no new rate is registered. Usually in SQL I can do this by placing the top item of an embedded selection in it, but I can not do this in access. I have also read that I can do it in the Staff Rate table to select the item that I want but can not apply the same argument to do this twice for the rate table to join.  

Update

According to the request, the following as I have found with the query it gives me the current and the rate of all the rate for the previous period Receives in, but I can not find any way to move it to the top.

  SELECT t.EmpNo, t.CostCode, t.Workstage, t.TimeCode_Desc, t.Line_Hours, t.Period_Month, t.Pieriod_Year, from srA.Rate (tbl time left as t On the side (t.Pieriod_Year = hrs.Pieriod_Year) and (t.Period_Month = include qryTotalHours as at.Period_Month) and (t.EmpNo = hrs.EmpNo)) left tblStaffRates as SRA on t.EmpN = SrA.EmpNo ou ((t.Pieriod_Month)> = [SRA] [Period_Month])).  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -