Grouping Date in SQL

A quick tutorial on how to Group Date in SQL

GROUPING DATE IN SQL
 
SELECT DATEPART(yy, Orders.[date]) AS [y],
       DATEPART(dy, Orders.[date]) AS [d],
       CONVERT(CHAR(12), Orders.[date], 106) AS [date],
       Count(Orders.[ORDER]) AS n
FROM
       [....]
WHERE
       [....]
GROUP BY
       DATEPART(yy, Orders.[date]),
       DATEPART(dy, Orders.[date]),
       CONVERT(CHAR(12), Orders.[date], 106)
ORDER BY
       DATEPART(yy, Orders.[date]),
       DATEPART(dy, Orders.[date])