- Select the name, job, and date of hire of the employees in department 20. (Format the HIREDATE column to MM/DD/YY)
Select ename,job,date_format(hiredate,' %m/%d/%Y') from emp2019274072 where deptno=20;
- Then format the HIREDATE column into DoW (day of the week), Day (day of the month), MONTH (name of the month) and YYYY(year)
Select ename,job,date_format(hiredate,' %a %D %b %Y') from emp2019274072 where deptno=20;
- Which employees were hired in April?
Select ename, hiredate from emp2019274072 where data_format(hiredata,’%m’)=’04’;
- Which employees were hired on a Tuesday?
Select ename,hiredate, date_format(hiredate,'%a') from emp2019274072 where date_format(hiredate,'%a')='Tue';
- Are there any employees who have worked more than 30 years for the company?
select ename,timestampdiff(year,hiredate,now()) as workmonth from emp2019274072 where timestampdiff(year,hiredate,now())>30;
07-05
3010
10-06
726
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交