Should I use a temporary table?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • murch.alexander@gmail.com

    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!
  • paii, Ron

    #2
    Re: Should I use a temporary table?


    <murch.alexande r@gmail.comwrot e in message
    news:5e7efac7-943e-4744-9a67-48ea3e822472@z7 2g2000hsb.googl egroups.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.


    Comment

    • murch.alexander@gmail.com

      #3
      Re: Should I use a temporary table?

      On Jun 2, 11:10 am, "paii, Ron" <n...@no.comwro te:
      <murch.alexan.. .@gmail.comwrot e in message
      >
      news:5e7efac7-943e-4744-9a67-48ea3e822472@z7 2g2000hsb.googl egroups.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?

      Comment

      • paii, Ron

        #4
        Re: Should I use a temporary table?


        <murch.alexande r@gmail.comwrot e in message
        news:e5a826d7-6739-466c-9faa-fac6b33f0d4f@k3 7g2000hsf.googl egroups.com...
        On Jun 2, 11:10 am, "paii, Ron" <n...@no.comwro te:
        <murch.alexan.. .@gmail.comwrot e in message
        news:5e7efac7-943e-4744-9a67-48ea3e822472@z7 2g2000hsb.googl egroups.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,sum Last90, 1)


        Comment

        Working...