sql Group by DateTime
Select Distinct CONVERT(varchar, myDate, 111) as TheDate, COUNT(id) as PerDay FROM orders Group By Convert(varchar, MyDate, 111) Order By PerDay Desc --also can use the following for date in YYYY-MM-DD: Select Distinct CONVERT(varchar(10), myDate, 120) as TheDate, COUNT(id) as PerDay FROM orders Group By Convert(varchar(10), MyDate, 120) Order By PerDay Desc
Groups a table by the date column, useful for Order reports etc.
Updated: Tuesday 11th October 2011, 11:33pm
There are 0 comments
Comments are currently closed.