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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:49:08+00:00 2026-05-14T00:49:08+00:00

I am creating a database that will help keep track of which employees have

  • 0

I am creating a database that will help keep track of which employees have been on a certain training course. I would like to get some guidance on the best way to design the database.

Specifically, each employee must attend the training course each year and my database needs to keep a history of all the dates on which they have attend the course in the past.

The end user will use the software as a planning tool to help them book future course dates for employees. When they select a given employee they will see:

  • (a) Last attendance date
  • (b) Projected future attendance date(i.e. last attendance date + 1 calendar year)

In terms of my database, any given employee may have multiple past course attendance dates:

EmpName          AttandanceDate

Joe Bloggs             1st Jan 2007
Joe Bloggs           4th Jan 2008
Joe Bloggs           3rd Jan 2009
Joe Bloggs           8th Jan 2010

My question is what is the best way to set up the database to make it easy to retrieve the most recent course attendance date? In the example above, the most recent would be 8th Jan 2010.

Is there a good way to use SQL to sort by date and pick the MAX date?

My other idea was to add a column called ‘MostRecent’ and just set this to TRUE.

EmpName    AttandanceDate         MostRecent
Joe Bloggs  1st Jan 2007           False
Joe Bloggs  4th Jan 2008           False
Joe Bloggs  3rd Jan 2009           False
Joe Bloggs  8th Jan 2010           True

I wondered if this would simplify the SQL i.e.

SELECT Joe Bloggs WHERE MostRecent = ‘TRUE’

Also, when the user updates a given employee’s attendance record (i.e. with latest attendance date) I could use SQL to:

  1. Search for the employee and set the
    MostRecent value to FALSE
  2. Add a new record with MostRecent set to TRUE?

Would anybody recommended either method over the other? Or do you have a completely different way of solving this problem?

  • 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-14T00:49:09+00:00Added an answer on May 14, 2026 at 12:49 am

    To get the last attendance date use the group function called MAX, i.e.

    SELECT MAX(AttandanceDate)  
    FROM   course_data
    WHERE  employee_name = 'Joe Bloggs'
    

    To get the max attendance date for all the employees:

    SELECT   employee_name, MAX(AttandanceDate)  
    FROM     course_data
    GROUP BY employee_name
    ORDER BY employee_name
    

    Query above will NOT return data for employees who haven’t attended any courses. So you need to execute a different query.

    SELECT   A.employee_name, B.AttandanceDate
    FROM     employee AS A
    LEFT JOIN (
               SELECT   employee_id, MAX(AttandanceDate) AS AttandanceDate
               FROM     course_data
               GROUP BY employee_id
              ) AS B ON A.id = B.employee_id
    ORDER BY A.employee_name
    

    For employees who haven’t attended any course, the query will return a NULL AttendanceDate.

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

Sidebar

Related Questions

I'm creating and app that will rely on a database, and I have all
I'm creating a report that will take some data from one database (Company and
I am creating a small application that will be deployed on Window. The database
I am creating a php backup script that will dump everything from a database
I have an ASPX page that is dynamically creating a gridview from a database
I'm creating a website that will have the admin upload documents available only to
I have a requirement to run a query against a database that will return
Hey there. I would really appreciate your help in creating a query that would
I am just learning Access and have been tasked with creating a database for
I need some help creating a query for my mySQL database. I have recently

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.