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:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5Zof-3aq2pWiGlivixrQxm63HifKFKLaq-L5y2MGBKESWxJizeOc54CnAhwlt5JpU7UGFErVb3J5t5U1H1LG6DqtdYGwLMkpVJyyR1y9IRabz4NMP9UMyVSQvRKEoX5V_Lce_Y8tOWowT/s320/group+by+year+month+date.jpg) |
Group by year, month and day in SQL Server |
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.