Hello all,
I've been trying to figure out the logic for this, thought I had it, then couldn't write up the SQL correctly, so I'll ask here.
I'm trying to send a letter to a list of employees notifying them of changes to the way they get paid.
Details
EMPL_INFO table contains employee ID and paygroup
PROCESS table has a date field that will be added to the letter. Field is called DT_PP_1.
PAY_CALENDAR has dates for when each paygroup gets their checks. It has a field called Check_DT.
I want to write an update query that will add the next pay date to the process table under DT_PP_1. I wrote this query to find the next date and it works fine.
I want to replace the 00E part with a sub query that will take an employee id from PROCESS table and look up that employee's paygroup in the EMPL_INFO table. Then I'd like to stick all that in an update query.
This is what I came up with, but getting syntax errors that I couldn't find/fix.
I'm hoping someone can help.
Thanks
I've been trying to figure out the logic for this, thought I had it, then couldn't write up the SQL correctly, so I'll ask here.
I'm trying to send a letter to a list of employees notifying them of changes to the way they get paid.
Details
EMPL_INFO table contains employee ID and paygroup
PROCESS table has a date field that will be added to the letter. Field is called DT_PP_1.
PAY_CALENDAR has dates for when each paygroup gets their checks. It has a field called Check_DT.
I want to write an update query that will add the next pay date to the process table under DT_PP_1. I wrote this query to find the next date and it works fine.
Code:
SELECT Min(PERIOD_CALENDAR.CHECK_DT) AS Expr1
FROM PERIOD_CALENDAR
WHERE (((PERIOD_CALENDAR.CHECK_DT)>Date()) AND ((PERIOD_CALENDAR.PAYGROUP)='00E'));
I want to replace the 00E part with a sub query that will take an employee id from PROCESS table and look up that employee's paygroup in the EMPL_INFO table. Then I'd like to stick all that in an update query.
This is what I came up with, but getting syntax errors that I couldn't find/fix.
Code:
UPDATE PROCESS SET PROCESS.DT_PP_1 = ( SELECT MIN(PERIOD_CALENDAR.CHECK_DT ) FROM PERIOD_CALENDAR WHERE (((PERIOD_CALENDAR.CHECK_DT)>DATE()) AND ((PERIOD_CALENDAR.PAYGROUP)='DLookup("Paygroup", "EMPL_INFO", "EMPLID=[PROCESS.EMPLID])'))
I'm hoping someone can help.
Thanks