Yesterday I got help on this SQL statement and it’s working fantastically… Now I’m trying to use data from this query to update two columns on a different table.
Here is the query as I have it:
SELECT x.TechID,
Count(*) AS cnt,
tblEmployeeData.LName,
tblEmployeeData.Pernr,
tblEmployeeData.Occurrences,
tblEmployeeData.Standing
FROM tblEmployeeData
INNER JOIN tblOccurrence AS x
ON tblEmployeeData.TechID = x.TechID
WHERE ( ( ( x.OccurrenceDate ) BETWEEN Dateadd("m", -6, Date()) AND Date() )
AND ( ( EXISTS (SELECT *
FROM tblOccurrence AS y
WHERE y.TechID = x.TechID
AND Dateadd ("d", -1, x.[OccurrenceDate]) = y.[OccurrenceDate]) ) = False ) )
GROUP BY x.TechID,
tblEmployeeData.LName,
tblEmployeeData.Pernr;
What I want to do is take the results and update the tblEmployeeData two columns. One column (tblEmployeeData.Occorrences) will be the value represented by ‘cnt’ … and then the tough part … the column tblEmployeeData.Standing will be updated using the value from ‘cnt’ as follows:
0-3 = "Good"
4-5 = "Verbal Warning"
6-7 = "Written Warning"
8 = "Final Written Warning"
9+ = "Termination"
It’s already a large SQL statement and this is going way above my head!
You can wrap a query in another query:
The idea is that you use the query with a
Ranktable, like so:Edit re comments
This runs for me in a rough mock-up