简单的sql查询问题
stamp times
2013-01-18 08:52:25.387 1
2013-01-18 10:05:12.107 1
2013-01-18 10:31:04.397 1
我想将上面的内容转换为
stamp times
2013-01-18 3
请问sql语句该怎么写?
------解决方案--------------------select convert(date,stamp)stamp ,sum(times)times
from tb
group by convert(date,stamp)stamp
------解决方案--------------------因为刚好你那个3就是所有加起来,所以我不知道你是想sum还是count,另外我这个语句是2008的,如果不是2008,可以这样:
select CONVERT(VARCHAR(10),stamp,114)stamp ,sum(times)times
from tb
group by CONVERT(VARCHAR(10),stamp,114)