MSSQL Group by 年月日

SQL Group by 年月日  

SELECT    'EVENT' AS 'table_name' , 
          datepart(yy, A.[TIMESTAMP]) AS 'yy' , 
          datepart(mm, A.[TIMESTAMP]) AS 'mm' , 
		  datepart(dd, A.[TIMESTAMP]) AS 'dd' , 
          count(*) AS 'count'
FROM      [dbo].[EVENT] AS A 
WHERE     A.[TIMESTAMP] >= '2017-01-01' 
GROUP BY  datepart(yy, A.[TIMESTAMP]) , 
          datepart(mm, A.[TIMESTAMP]),
		  datepart(dd, A.[TIMESTAMP])
		   order by 
		   datepart(yy, A.[TIMESTAMP]) , 
		  datepart(mm, A.[TIMESTAMP]) , 
          datepart(dd, A.[TIMESTAMP])


你可能感兴趣的:(数据库)