verizonrep
Programmer
I am trying make a query that takes order data for reps and adds their program "PlanID" based on their start date. The challenge has been that they can change programs mid year, so I need it to reflect the correct plan with the correct month. Here's an example (note that there are really 500,000 lines of data carrying multiple salespeople). The data is in a "Bookings_Tbl" and the employees plan is in a "Positions_Tbl". Note that all months (both PayMonth and StartMonth are as of the 1st.
Bookings_Tbl
OrderNumber EmployeeID PayMonth
O54687 11111 1/1/2005
O65487 22222 1/1/2005
O879461 33333 1/1/2005
(list goes on for 500,000 records for months 1-6 of this year).
Position_Tbl
EmployeeID StartMonth PlanID
11111 1/1/2005 5001
22222 1/1/2005 5001
33333 1/1/2005 5001
22222 3/1/2005 3001
I want to run the query against orders and have it return the proper PlanID. This has a order number, process month, and employee number (in order to keep this short, I'll just focus on data for rep 22222 since he was the only one with a change).
Order ProcessMonth EmployeeID PlanID
O12345 1/1/2005 22222 5001
O45677 2/1/2005 22222 5001
O46884 3/1/2005 22222 3001
Anyone have any ideas? This one has given me nothing but problems for quite a while. I've tried to use Domain Aggregate functions, but I don't know how to do this based on two fields (EmployeeID and ProcessMonth).
Thanks
Verizonrep
Bookings_Tbl
OrderNumber EmployeeID PayMonth
O54687 11111 1/1/2005
O65487 22222 1/1/2005
O879461 33333 1/1/2005
(list goes on for 500,000 records for months 1-6 of this year).
Position_Tbl
EmployeeID StartMonth PlanID
11111 1/1/2005 5001
22222 1/1/2005 5001
33333 1/1/2005 5001
22222 3/1/2005 3001
I want to run the query against orders and have it return the proper PlanID. This has a order number, process month, and employee number (in order to keep this short, I'll just focus on data for rep 22222 since he was the only one with a change).
Order ProcessMonth EmployeeID PlanID
O12345 1/1/2005 22222 5001
O45677 2/1/2005 22222 5001
O46884 3/1/2005 22222 3001
Anyone have any ideas? This one has given me nothing but problems for quite a while. I've tried to use Domain Aggregate functions, but I don't know how to do this based on two fields (EmployeeID and ProcessMonth).
Thanks
Verizonrep