本文介绍了如何获得每个部门最近加入的员工详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表Emp和Dept.Emp由Empno(pk),Deptno(FK),Ename,Hiredate组成,Dept由Deptno(pk),Dname,Loc组成.
我想查询所有最近加入该部门的员工的所有详细信息.

i have two tables Emp and Dept. Emp consists of Empno(pk),Deptno(FK),Ename,Hiredate and Dept consists Deptno(pk),Dname,Loc.
I want query to get all details of employee who joined recently in each department.

推荐答案

SELECT E.*,D.* FROM Emp E INNER JOIN Dept D ON E.Deptno = D.Deptno
WHERE CONVERT(VARCHAR,E.Hiredate,101) > CONVERT(VARCHAR,DATEADD(DAY,-30,GETDATE()),101)
Order by D.Dname, E.Hiredate Desc,  E.Ename




它只会显示最近30天内加入的那些员工.但是如果您想增加或减少天数,请用您的值替换-30.


我希望这能帮到您! :)


如果您仍然没有解决办法,请告诉我.

谢谢,
Imdad




It will display only those employee who was joined in last 30 days. but if you want increase or decrease day replace -30 with your value.


I hope this will help you! :)


Please let me know, if still you don''t have solution.

Thanks,
Imdad


这篇关于如何获得每个部门最近加入的员工详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:52