Hi all,
I posted here last week with a simplified version of the following. I
didn't get many responses, so I'm going for the more detailed
explanation. Here's the problem:
We have a point-based program for our employee attendance policy. That
is, when an emp is late, they get 1/2 point, when they skip work, they
get 3 points, etc. At certain point thresholds, they receive different
discipline steps... for example, when they hit 6 points, they get a
verbal warning, at 9 points, they get a written warning, etc. The
catch is that when they go a certain amount of time (90 days) without
incident, one point is subtracted from their total. If they go 180
days, their point total is reset to zero. My ideal strategy is to
store only the data related to employee point accumulation. I want the
database, through a series of queries to tell me when the points
disappear.
So far, I've created a query that looks forward and finds the date of
each employee's next attendance issue. In other words, if an employee
has attendance problems on 5/1/06 and 11/31/06, the query will tell me
the time difference between the two. If there is no next issue, it
uses today's date. It then figures out how many days are between this
event and the next one to find out if one or all points can be
removed. I created two additional queries to tell me the exact dates
on which I can remove one point or all points.
Now I want to create a single query to give me a point history for
each employee over time. So, basically, I'll be showing the records
from the attendance issues table and inserting "on the fly" records of
point deductions as I go along. I've come close, but there are two
problems: I don't know how many points I can subtract when I want to
get rid of all points. I tried just using 100, but then the emp goes
into negative points, when in reality, they can only go as low as
zero. Also, when I try to add up a subtotal of points, I have to
recalculate the point subtotal which is a recursive nightmare.
Would temporary tables (to store the data from my calculation-heavy
queries) be a better solution? Any advice would be greatly
appreciated. Thanks!
I posted here last week with a simplified version of the following. I
didn't get many responses, so I'm going for the more detailed
explanation. Here's the problem:
We have a point-based program for our employee attendance policy. That
is, when an emp is late, they get 1/2 point, when they skip work, they
get 3 points, etc. At certain point thresholds, they receive different
discipline steps... for example, when they hit 6 points, they get a
verbal warning, at 9 points, they get a written warning, etc. The
catch is that when they go a certain amount of time (90 days) without
incident, one point is subtracted from their total. If they go 180
days, their point total is reset to zero. My ideal strategy is to
store only the data related to employee point accumulation. I want the
database, through a series of queries to tell me when the points
disappear.
So far, I've created a query that looks forward and finds the date of
each employee's next attendance issue. In other words, if an employee
has attendance problems on 5/1/06 and 11/31/06, the query will tell me
the time difference between the two. If there is no next issue, it
uses today's date. It then figures out how many days are between this
event and the next one to find out if one or all points can be
removed. I created two additional queries to tell me the exact dates
on which I can remove one point or all points.
Now I want to create a single query to give me a point history for
each employee over time. So, basically, I'll be showing the records
from the attendance issues table and inserting "on the fly" records of
point deductions as I go along. I've come close, but there are two
problems: I don't know how many points I can subtract when I want to
get rid of all points. I tried just using 100, but then the emp goes
into negative points, when in reality, they can only go as low as
zero. Also, when I try to add up a subtotal of points, I have to
recalculate the point subtotal which is a recursive nightmare.
Would temporary tables (to store the data from my calculation-heavy
queries) be a better solution? Any advice would be greatly
appreciated. Thanks!
Comment