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 2008 Forums
 Transact-SQL (2008)
 ssms query(2008)

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2012-06-06 : 08:58:40
dear all

i have to create a query

i need to calculate count of employees in every month in

any body knows

pls explain the logic

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-06 : 09:02:25
select convert(varchar(6),dte,112), count(*)
from tbl
group by convert(varchar(6),dte,112)

Depends on what your data looks like.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-07 : 22:59:26
[code]
select year(datefield),month(datefield),count(*)
from table
group by year(datefield),month(datefield)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -