Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8394727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:07:56+00:00 2026-06-09T20:07:56+00:00

Yesterday I got help on this SQL statement and it’s working fantastically… Now I’m

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:07:58+00:00Added an answer on June 9, 2026 at 8:07 pm

    You can wrap a query in another query:

    SELECT TechID, Rank FROM Rank,
    (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) a
    WHERE a.Cnt BETWEEN Rank.Low And rank.High
    

    The idea is that you use the query with a Rank table, like so:

    Low High    Rank
    0   3       Good
    4   5       Verbal Warning
    6   7       Written Warning
    8   8       Final Written Warning
    9   99      Termination
    

    Edit re comments

    This runs for me in a rough mock-up

    SELECT a.TechID, tblRank.Rank FROM tblRank, (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, tblEmployeeData.Occurrences, tblEmployeeData.Standing) a
    WHERE a.Cnt BETWEEN tblRank.Low And tblrank.High
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks to some help I received yesterday I've got some dynamic summing working on
I'm sure my app worked right until yesterday, when I got this error: Failed
this is a follow up to a question I got help with on here
I asked a question yesterday on here and got some awsome help, but I
This is a expansion on to a previous question that got answered yesterday, which
Tried to rebuild an app that was working just yesterday. Got a message that
Last week we submitted our app to apple. Yesterday we got response from them.
I asked this question yesterday got a pretty good answer but can't figure out
I didn't find any question like this here. Yesterday I finally got Gingerbread 2.3.4
Yesterday I got a call from a Microsoft representative asking if we supply hosted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.