如何获得每年的员工数量 [英] How to get number of employees per year

查看:76
本文介绍了如何获得每年的员工数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我有一张名为Mst_Employee的表。字段是<​​br />


Emp_No
Emp_Name

Emp_JoiningDate

Emp_ResignedDate

Emp_Status





如何按年份获得员工人数。

每年有人加入或辞职。



例如结果看起来像这样

年-----不。员工。

2011 ---- 125

2012 ----- 130

2013 ----- 100


请帮助这个

谢谢

Basit。

Dear,

I have a table called Mst_Employee.Field are

Emp_No
Emp_Name
Emp_JoiningDate
Emp_ResignedDate
Emp_Status


How to get the No. of Employees by Year.
Each year somebody join or resigned.

E.g. Result look like this
Year-----No. of Employees.
2011---- 125
2012-----130
2013-----100

Please help on this
Thanks
Basit.

推荐答案

按功能和计数使用组。



请参阅以下链接

http://www.w3schools.com/sql/sql_groupby.asp [ ^ ]



此网站还将帮助您提取月份部分约会。



首先尝试这个,如果您有其他问题,请告诉我们。
Use a group by function and count.

Refer to the following link
http://www.w3schools.com/sql/sql_groupby.asp[^]

This site will also help you extract out the month part of the date.

Try this first and if you have further issues let us know.


试试这个



try this

select JY,Sum(TotalCount) from (
select JY,Sum(x.CJM) over(order by JY  ROWS UNBOUNDED PRECEDING) as TotalCount from (
select * from (
select Row_Number() over (order by year(Emp_JoiningDate))as ID,year(Emp_JoiningDate)as JY,Count(year(Emp_JoiningDate))as CJM from ##Emp
group by year(Emp_JoiningDate))JoingData
Union ALL
select * from (
select Row_Number() over (order by year(Emp_ResignedDate))as ID,year(Emp_ResignedDate)as JY,-Count(year(Emp_ResignedDate))as CRM from ##Emp
where Emp_ResignedDate is not null group by year(Emp_ResignedDate))ResignedData
) as x )y group by JY


请尝试以下操作。



Try following.

Select year(emp_joiningdate),count(emp_no)
from Mst_Employee 
where emp_resigneddate is null
Group by year(emp_joiningdate) 







如果这不起作用,请回答它给出的问题。




If this doesn't work write me back with the problem it gives.


这篇关于如何获得每年的员工数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆