Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Month wise employee count

Author  Topic 

Jabez
Starting Member

19 Posts

Posted - 2007-04-26 : 04:30:06
Hi Folks,

Please help me in writing a query. I need to get current strength of employee's, monthwise (till each month).

Table Structure
----------------
Employee_Master

ED_EmpId ED_DOJ ED_Name
-------- ------- ---------
2006-01-02 SRINIVASA
2006-01-02 KAVITA
2006-01-02 VIVEK
2006-02-20 CHANDRA
2006-02-25 PARIMAL
2006-02-30 SATISH
........
2007-01-10 SANJEEV SHARMA
2007-01-14 JITENDRA PRATAP SINGH
2007-03-15 SANDEEP
2007-03-02 SUNIL KUMAR SHARMA


I require the data in the below format..

For the year '2007-2008'

Month Count
----- -----
April(07) 10
May . 10
June . 10
July . 10
August . 10
Sept 10
Oct 10
Nov 10
Dec 10
Jan (08) 10
Feb . 10
March . 10



Thanks.








SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-26 : 04:32:51
Something similar to

SELECT DATENAME(year, ED_DOJ), DATENAME(month, ED_DOJ), count(*)
FROM Employee_Master
GROUP BY DATENAME(year, ED_DOJ), DATENAME(month, ED_DOJ)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

naveen901
Starting Member

2 Posts

Posted - 2007-04-26 : 07:20:05
Hi

try this

select datename(year,ed_doj),datename(month,ed_doj),count(*) from employee_master group by ed_doj

perhaps this might help you

thanks

naveen.
Go to Top of Page
   

- Advertisement -