比如一张表里有如下时间字段的记录:
2009-01-01 12:00:00
2008-12-23 11:00:11
2009-12-22 11:22:00
2009-01-01 14:00:00
2009-12-22 12:00:09
通过以下的代码段进行group by之后重排序得到新的结果。
select convert(varchar(10), starttime,20) as 'dailydate' from table1 group by convert(varchar(10), starttime,20)
结果如下:
2009-01-01
2008-12-23
2009-12-22