• Question

  • Hey guys, I am insanely a newb so sorry if I posted in the wrong forum. I currently have a table right now with a list of employees, managers, and other jobs. How would I able to get a list of all the employees who are older than their managers if their DOB is in YYYY-MM-DD form? This is really urgent and I really hope someone can help a newbie :(
    Wednesday, April 10, 2019 1:09 AM


  • There are quite a few things which would require confirmation so I'm assuming few facts here

    Assuming your DOB column is a datetime column and your employees have columns EmpID, EmpName,MgrID and DOB the query would look like this

    SELECT e.EmpName,e.DOB AS EMpDOB,m.EmpName AS MgrName,m.DOB AS MgrDOB
    FROM EmployeeTable e
    JOIN EmployeeTable m
    ON m.EmpID = e.MgrID
    WHERE m.DOB < e.DOB

    This will give you names of all employees with DOB later than (older) their managers

    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Wednesday, April 10, 2019 5:56 AM

All replies