Home > database >  Select employees whose employment date is equal to the first date of hire date for 10 years
Select employees whose employment date is equal to the first date of hire date for 10 years

Time:01-20

I want to select * from employees where hire date is equal min hire_date 10 years but it not work.

enter image description here

CodePudding user response:

I can't see images, but - as you explained it, query would look like this:

select *
from employees
where hiredate = (select add_months(min(hiredate), 12 * 10)
                  from employees
                 )

CodePudding user response:

SELECT * FROM employees WHERE NOW() = DATE_ADD(hire_date, INTERVAL 10 YEAR) ORDER BY hire_date;
  •  Tags:  
  • Related