Thread: MS SQL Server General Questions/Group query by hours and by days

Group query by hours and by days

Here it is by hours first:


Convert(varchar(2), [EndDate],114) as hh,count(*) from [dbo].[Vote] group by Convert(varchar(2), [EndDate],114)


order by Convert(varchar(2), [EndDate],114)


And now by days:



Convert(varchar(8), [EndDate],112) as dd,count(*) from [dbo].[Vote] group by Convert(varchar(8), [EndDate],112)


order by Convert(varchar(8), [EndDate],112)