473,320 Members | 2,097 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Should I use a temporary table?

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!
Jun 27 '08 #1
3 1089

<mu*************@gmail.comwrote in message
news:5e**********************************@z72g2000 hsb.googlegroups.com...
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!
Is each problem dated? If so sum all records more then 180 days old then
subtract 1 from each record where the sum of record's dated more then 90
days is greater then 1.
Jun 27 '08 #2
On Jun 2, 11:10 am, "paii, Ron" <n...@no.comwrote:
<murch.alexan...@gmail.comwrote in message

news:5e**********************************@z72g2000 hsb.googlegroups.com...
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!

Is each problem dated? If so sum all records more then 180 days old then
subtract 1 from each record where the sum of record's dated more then 90
days is greater then 1.
You just took elegant to a whole new level. This might very well do
the trick! The only remaining issue I have is that, sometimes, a
person might have only a half-point on his or her record. How can I
make only the 1/2 point go away without making the sum -1/2?
Jun 27 '08 #3

<mu*************@gmail.comwrote in message
news:e5**********************************@k37g2000 hsf.googlegroups.com...
On Jun 2, 11:10 am, "paii, Ron" <n...@no.comwrote:
<murch.alexan...@gmail.comwrote in message
news:5e**********************************@z72g2000 hsb.googlegroups.com...


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!
Is each problem dated? If so sum all records more then 180 days old then
subtract 1 from each record where the sum of record's dated more then 90
days is greater then 1.

You just took elegant to a whole new level. This might very well do
the trick! The only remaining issue I have is that, sometimes, a
person might have only a half-point on his or her record. How can I
make only the 1/2 point go away without making the sum -1/2?
iif( sumLast90<1,sumLast90, 1)
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Corrine | last post by:
Hi, I am creating a global temporary table that is session-specific. I insert a BLOB into this table, and then select the BLOB from this table into a ResultSet. The ResultSet sees this BLOB...
5
by: Jim Garrison | last post by:
Scenario: 1) Create a GLOBAL TEMPORARY table and populate it with one (1) row. 2) Join that table to another with about 1 million rows. The join condition selects a few hundred rows. ...
4
by: gonzal | last post by:
Hi Dose any body know why a temporary table gets deleted after querying it the first time (using SELECT INTO)? When I run the code bellow I'm getting an error message when open the temp table...
11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
0
by: nedbollard | last post by:
Hi, Having checked out a declared (rather than created) temporary table successfully in SPUFI, I have hit a problem in running the same SQL in the cobol prog I am ameding to use it. I have:...
7
by: Larry | last post by:
Hi, I have unbelievable problems just to save a record! I make an input to a record in a subform, which has a temporary table as its recordsource. When I am done, and want to save the...
5
by: Adam W. Saxton | last post by:
We have a few existing stored procedures which create a Global Temporary Table (##), do some work on the table and then delete the table. The issue we have is that if our Server application is...
3
by: AFN | last post by:
I need to manually create the data to be shown in a datagrid (or some data table object). Should I create an array and bind the array to the datagrid OR should I create a temporary dataset and...
11
by: rawu | last post by:
hi , all . I got a question about creating indexes in db2 . a table has 44236333 rows an index planed to be build include 2 field ( 6 byte ) accordding to db2 document temporary...
6
by: Troels Arvin | last post by:
Hello, I have recently run a rather large data import where the imported data i pumped through some updatable views equipped with INSTEAD OF triggers. For various reasons, the exact same data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.