请问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-01 22611815 403564
2007-12-01 22612343 403564
2007-12-01 22612342 403564
2007-12-01 22611816 403564
2007-12-01 22612343 403564
2007-12-01 22611816 403564
2007-12-01 22611814 403564
2007-12-01 22611815 403564
2007-12-02 22612343 403564
2007-12-02 22611815 403564
2007-12-02 22612342 403564
2007-12-02 22611816 403564
2007-12-02 22611816 403564
2007-12-02 22612343 403564
2007-12-02 22611815 403564
2007-12-03 22612342 403564
2007-12-03 22611815 403564
2007-12-03 22612343 403564
2007-12-03 22611816 403564
2007-12-03 22612343 403564
2007-12-03 22611816 403564
2007-12-03 22611816 403564
2007-12-03 22612342 403564
2007-12-04 22611815 403564
2007-12-04 22611815 403564
2007-12-04 22612342 403564
2007-12-04 22612343 403564
2007-12-04 22612343 403564
2007-12-04 22611816 403564
2007-12-04 22611816 403564
2007-12-05 22612342 403564
2007-12-05 22611815 403564
2007-12-05 22612343 403564
2007-12-05 22611816 403564
2007-12-05 22612343 403564
2007-12-05 22611816 403564
2007-12-05 22611814 403564
2007-12-06 22612342 403564
2007-12-06 22611815 403564
2007-12-06 22611816 403564
2007-12-06 22612343 403564
2007-12-06 22611816 403564
2007-12-06 22611816 403564
2007-12-06 22612343 403564
2007-12-07 22612343 403564
2007-12-07 22611816 403564
2007-12-07 22611815 403564
2007-12-07 22612342 403564
2007-12-07 22611816 403564
2007-12-07 22612343 403564
2007-12-07 22612343 403564
2007-12-08 22612343 403564
2007-12-08 22611815 403564
2007-12-08 22612342 403564
2007-12-08 22611816 403564
2007-12-08 22612343 403564
2007-12-08 22611816 403564
2007-12-08 22611814 403564
2007-12-09 22612342 403564
2007-12-09 22611815 403564
2007-12-09 22611815 403564
2007-12-09 22612343 403564
2007-12-09 22611816 403564
2007-12-09 22611816 403564
2007-12-10 22611815 403564
2007-12-10 22611816 403564
2007-12-10 22612342 403564
2007-12-10 22611816 403564
2007-12-10 22612343 403564
2007-12-10 22612343 403564
2007-12-10 22611816 403564
2007-12-10 22611814 403564
2007-12-10 22611815 403564
2007-12-11 22612342 403564
2007-12-11 22612343 403564
2007-12-11 22611815 403564
2007-12-11 22611816 403564
2007-12-11 22611816 403564
2007-12-11 22612343 403564
2007-12-11 22611814 403564
2007-12-11 22612342 403564
2007-12-12 22612342 403564
2007-12-12 22611815 403564
2007-12-12 22611814 403564
2007-12-12 22612343 403564
2007-12-12 22611816 403564
2007-12-12 22611816 403564
2007-12-12 22611815 403564
------解决方案--------------------
- 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