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 7178731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:58:44+00:00 2026-05-28T16:58:44+00:00

I have a MS Access database for employee training and there is a class

  • 0

I have a MS Access database for employee training and there is a class that each employee is required to have twice a year.

The table for that class looks like this:

EmployeeID  ClassDate   ClassHours
1           1/1/2011        8
1           7/31/2011       7
2           2/1/2011        8
2           8/31/2011       7
3           3/1/2011        8
3           9/30/2011       7   

I want the table to be formated like this:

EmployeeID  ClassDate_1 ClassHours_1    ClassDate_2 ClassHours_2
1           1/1/2011        8           7/31/2011       7
2           2/1/2011        8           8/31/2011       7   
3           3/1/2011        8           9/30/2011       7   

How do I write a query to move the second class date and hour fields to the same row based off the EmployeeID?

I have researched through this site and all the possible solutions appear to be overly complicated for what I am trying to acheive.

Your help is greatly appreciated.

Thanks

  • 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-05-28T16:58:45+00:00Added an answer on May 28, 2026 at 4:58 pm

    You will have to create a query with a sub-select

    SELECT
        X.EmployeeID,
        X.d1 AS ClassDate_1, ec1.ClassHours AS ClassHours_1,
        X.d2 AS ClassDate_2, ec2.ClassHours AS ClassHours_2
    FROM
        ( (SELECT e.EmployeeID, Min(e.ClassDate) AS d1, Max(e.ClassDate) AS d2
           FROM employee_classes AS e
           GROUP BY e.EmployeeID) AS X
          INNER JOIN employee_classes AS ec1
              ON X.EmployeeID = ec1.EmployeeID AND X.d1 = ec1.ClassDate
        )
        INNER JOIN employee_classes AS ec2
            ON X.EmployeeID = ec2.EmployeeID AND X.d2 = ec2.ClassDate;
    

    Alternatively you could store the nested select as a query (let’s call it query1):

    SELECT e.EmployeeID, Min(e.ClassDate) AS d1, Max(e.ClassDate) AS d2
    FROM employee_classes AS e
    GROUP BY e.EmployeeID
    

    and then use it in a second query

    SELECT
        X.EmployeeID,
        X.d1 AS ClassDate_1, ec1.ClassHours AS ClassHours_1,
        X.d2 AS ClassDate_2, ec2.ClassHours AS ClassHours_2
    FROM
        ( query1 AS X
          INNER JOIN employee_classes AS ec1
              ON X.EmployeeID = ec1.EmployeeID AND X.d1 = ec1.ClassDate
        )
        INNER JOIN employee_classes AS ec2
            ON X.EmployeeID = ec2.EmployeeID AND X.d2 = ec2.ClassDate;
    

    It would be much easier if the hours were not displayed

    SELECT e.EmployeeID, Min(e.ClassDate) AS ClassDate_1, Max(e.ClassDate) AS ClassDate_2
    FROM employee_classes AS e
    GROUP BY e.EmployeeID
    

    Indeed there is a simpler solution, however it assumes that the table is sorted by EmployeeID and ClassDate. This assumption is not safe, as no natural sort order is guaranteed. Access can “decide” to reorganize the records in a different way at any time.

    SELECT
        EmployeeID,
        First(ClassDate) AS ClassDate_1, First(ClassHours) AS ClassHours_1,
        Last(ClassDate) AS ClassDate_2,  Last(ClassHours) AS ClassHours_2
    FROM
        employee_classes
    GROUP BY
       EmployeeID
    ORDER BY
       EmployeeID;
    

    Here again a sub-select can help

    SELECT
        EmployeeID,
        First(ClassDate) AS ClassDate_1, First(ClassHours) AS ClassHours_1,
        Last(ClassDate) AS ClassDate_2,  Last(ClassHours) AS ClassHours_2
    FROM
        (SELECT * FROM employee_classes ORDER BY EmployeeID, ClassDate)
    GROUP BY
       EmployeeID
    ORDER BY
       EmployeeID;
    

    Howsoever, either a sub-query or a second query is required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Access database in which I drop the table and then create
I have an Access Database that outputs a report in Excel format. The report
I have a Microsoft Access database query that I'm trying to import into a
I have an access 2007 Database that outputs a report in excel format, the
I'm creating a HR database in access 2007 I have a main table of
I have an organizational database where in it each employee have a foreign key
I have an existing Access database which contains training records for employees. If an
I have an access database that is saved in a network location so that
I have a program that uses a Microsoft Access database for its back-end. I
We have a certain database that has some employee information, and I just wrote

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.