select year(time) 年,month(time) 月,day(time) 日,sum(num) from tablegroup by year(time),month(time),day(time)或者select convert(char(8),time,112) dt,sum(num) from tablegroup by convert(char(8),time,112)