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 |
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.