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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query for muliple column selection

Author  Topic 

Agalo
Starting Member

1 Post

Posted - 2009-04-25 : 07:13:17
I have a table employee , containing following information

ID Name Date Joined
1 abc 4/31/2009
2 d 1/5/2009
3 e 6/3/2009
4 f 10/10/2008
5 g 4/16/2009
6 h 2/2/2009
7 j 7/19/2009


I want result set which gives details of how many employee joined on monthly basis for a year. If user selects a date 6/20/2008 I want output to be begin from 6 month of 2008 to 5 month of 2009 i.e One year.
I want total number of employees i.e cumulative sum , beginning from selected month.

Required Output: If user selects 6/20/2008

JUN'08 JUL '08 ........ NOV '08 DEC '08 JAN '09 ..... APR '09 MAY '09
0 0 1 1 2 4 4

I am struggling with the query to get this output. I want only one sql query for doing this.


Any help will be greatly appreciated.
Thanks in advance.
   

- Advertisement -