Group by year, month and day in SQL Server

Group by year, month and day in SQL Server


--------------------------------------------------------------
Select Year(HireDate) as year, 
datename(mm,HireDate)+ ' '+cast(day(HireDate) as varchar) MonthDay,
count(JobTitle) as TotalEmployees,JobTitle
from [AdventureWorks2008R2].[HumanResources].[Employee] 
Group by 
 year(HireDate),
 month(HireDate),
 day(hiredate),
 datename(mm,HireDate),
 JobTitle
 
Order by 
 year(HireDate),
 month(HireDate),
  day(hiredate),
 datename(mm,HireDate)
---------------------------------------------------------------


Output:

Group by year, month and day in SQL Server



Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar