DATENAME和DATEPART有何区别,Insus.NET写成一个函数,可以方便查询与对比: 一个是返回一个字符串,另一个是返回一个整数. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Insus.NET -- Create date: 2019-05-10 -- Update date: 2019-05-10 -- De…
1.使用 DATENAME() 函数 SELECT DATENAME(yyyy, [columnName]) + '/' + DATENAME(mm, [columnName]) AS monthDate,COUNT(*) AS number FROM [tableName]GROUP BY DATENAME(yyyy, [columnName]) ,DATENAME(mm, [columnName])ORDER BY monthDate DESC 结果如下: DATENAME ( datepa…