Pull up only recent dates from employees who have multiple records with multiple date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sandra1
    New Member
    • May 2014
    • 5

    Pull up only recent dates from employees who have multiple records with multiple date

    i have an employee database,my employees have multiple change forms with diff dates, but i only want to find the most recent date from each employee. How do i do that?
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    Welcome to Bytes.

    Depends on how you are wanting to view the information. In a query? In a textbox? We need more information to be able to properly help you.

    Comment

    • sandra1
      New Member
      • May 2014
      • 5

      #3
      i want to view it in a query

      Comment

      • sandra1
        New Member
        • May 2014
        • 5

        #4
        i have a query with fields of, first name, last name, work cell number, work cell type, is active and change form date. So when i run it all the dates from the change form date field come up, bt i only want to see the most recent date of each employee.

        Comment

        • Seth Schrock
          Recognized Expert Specialist
          • Dec 2010
          • 2965

          #5
          Can you post the query's SQL code (See Before Posting (VBA or SQL) Code). If your data is properly normalized, then it will be very simple to do. If not (then it should be) we will have to do a little trick to get it to work. Your SQL code will tell me which method is needed.

          Comment

          • sandra1
            New Member
            • May 2014
            • 5

            #6
            Code:
            SELECT Employee.FirstName, Employee.LastName, EmployeeInfo.WorkCellNumber, EmployeeInfo.WorkCellType, Employee.IsActive, EmployeeInfo.ChangeFormDate
            FROM Employee INNER JOIN EmployeeInfo ON Employee.EmployeeID = EmployeeInfo.EmployeeID;
            Last edited by Rabbit; May 8 '14, 10:20 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #7
              Wonderful. Okay, this is just air code as I don't have a system up to be able to test it, but this should be close if not perfect.
              Code:
              SELECT E.FirstName
              , E.LastName
              , EI.WorkCellNumber
              , EI.WorkCellType
              , E.IsActive
              , EI.ChangeFormDate
              FROM Employee As E INNER JOIN 
              	(
              		SELECT EmployeeID
              		, WorkCellNumber
              		, WorkCellType
              		, Max(ChangeFormDate)
              		FROM EmployeeInfo
              		GROUP BY EmployeeID
              	) As EI
              	ON E.EmployeeID = EI.EmployeeID

              Comment

              • sandra1
                New Member
                • May 2014
                • 5

                #8
                There must be something im doing wrong, because it wont let me run it, it keeps sayin syntax error in JOIN operation.

                Comment

                • Seth Schrock
                  Recognized Expert Specialist
                  • Dec 2010
                  • 2965

                  #9
                  Please post what you have using the [CODE/] button to add the required code tags for you.

                  You might try running just the subquery on it own. Just copy the code between the parenthesis into a new query window and then try to run it and see if there is an error.
                  Last edited by Seth Schrock; May 9 '14, 03:39 PM. Reason: Added something to try.

                  Comment

                  Working...