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.
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.

Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Jun 29, 2015, 10:38 PM EDT
SELECT [YEAR] , COUNT(Emp_No) AS [No. of Employees.] FROM
(
SELECT e.Emp_No, DATEPART(YYYY, e.Emp_JoiningDate)AS [YEAR] FROM dbo.Employees e
)EMP
Narasimha Reddy ChennupalliRank #1,163 · 1.6K reputationPosted Jul 4, 2015, 10:12 AM EDT
with EmployeeStartFinYear(FinYear, EmployeeId)
as
(
select year(dateadd(M,-3,JoinDate)), EmployeeId
from Employees
where JoinDate is not null
)
select FinYear, count(EmployeeId)
from EmployeeStartFinYear
group by FinYear
order by FinYear;
Note: The above example shows the employee count by financial year.
Raja TRank #685 · 3.5K reputationPosted Jul 6, 2015, 8:47 PM EDT
Govinda Rajulu YemineniRank #1,518 · 1K reputationPosted Jul 9, 2015, 12:57 AM EDT