首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教sqlserver中按日期分类的函数如何写

2012-02-02 
请问sqlserver中按日期分类的函数怎么写请问sqlserver中按日期分类的函数怎么写 ,我想按月份和keywid和use

请问sqlserver中按日期分类的函数怎么写
请问sqlserver中按日期分类的函数怎么写 ,我想按月份和keywid和userid来显示

select DATE_FORMAT(stdate,'%Y-%m-1') as date1,count(distinct keywid),userid 
 from [12gjcc-1]
 group by date1,userid 我这样写提示DATE_FORMAT函数名不可识别!! 高手请指点 下面是表 我没有全给出 只是12月份德一部分

date keywid userid
2007-12-0122611815403564
2007-12-0122612343403564
2007-12-0122612342403564
2007-12-0122611816403564
2007-12-0122612343403564
2007-12-0122611816403564
2007-12-0122611814403564
2007-12-0122611815403564
2007-12-0222612343403564
2007-12-0222611815403564
2007-12-0222612342403564
2007-12-0222611816403564
2007-12-0222611816403564
2007-12-0222612343403564
2007-12-0222611815403564
2007-12-0322612342403564
2007-12-0322611815403564
2007-12-0322612343403564
2007-12-0322611816403564
2007-12-0322612343403564
2007-12-0322611816403564
2007-12-0322611816403564
2007-12-0322612342403564
2007-12-0422611815403564
2007-12-0422611815403564
2007-12-0422612342403564
2007-12-0422612343403564
2007-12-0422612343403564
2007-12-0422611816403564
2007-12-0422611816403564
2007-12-0522612342403564
2007-12-0522611815403564
2007-12-0522612343403564
2007-12-0522611816403564
2007-12-0522612343403564
2007-12-0522611816403564
2007-12-0522611814403564
2007-12-0622612342403564
2007-12-0622611815403564
2007-12-0622611816403564
2007-12-0622612343403564
2007-12-0622611816403564
2007-12-0622611816403564
2007-12-0622612343403564
2007-12-0722612343403564
2007-12-0722611816403564
2007-12-0722611815403564
2007-12-0722612342403564
2007-12-0722611816403564
2007-12-0722612343403564
2007-12-0722612343403564
2007-12-0822612343403564
2007-12-0822611815403564
2007-12-0822612342403564
2007-12-0822611816403564
2007-12-0822612343403564
2007-12-0822611816403564
2007-12-0822611814403564
2007-12-0922612342403564
2007-12-0922611815403564
2007-12-0922611815403564
2007-12-0922612343403564
2007-12-0922611816403564
2007-12-0922611816403564
2007-12-1022611815403564
2007-12-1022611816403564
2007-12-1022612342403564
2007-12-1022611816403564
2007-12-1022612343403564
2007-12-1022612343403564
2007-12-1022611816403564
2007-12-1022611814403564
2007-12-1022611815403564
2007-12-1122612342403564
2007-12-1122612343403564
2007-12-1122611815403564
2007-12-1122611816403564
2007-12-1122611816403564
2007-12-1122612343403564
2007-12-1122611814403564
2007-12-1122612342403564
2007-12-1222612342403564
2007-12-1222611815403564
2007-12-1222611814403564
2007-12-1222612343403564
2007-12-1222611816403564
2007-12-1222611816403564
2007-12-1222611815403564


[解决办法]

SQL code
select DATEpart(mm,stdate) as date1,count(distinct keywid),userid   from [12gjcc-1]  group by DATEpart(mm,stdate),userid
[解决办法]
select DATEpart(mm,stdate) as date1,count(distinct keywid),userid
 from [12gjcc-1] 
 group by DATEpart(mm,stdate),userid

[解决办法]
SQL code
select convert(varchar(7),stdate,120) as date1,count(distinct keywid),userid   from [12gjcc-1]  group by convert(varchar(7),stdate,120),userid 

热点排行