sql按半小时统计

时间:2022-04-25 04:00:46

floor(4.4)  结果为4,浮点转整型

(DATE_FORMAT(PrtTime,‘%H‘)     取小时h

DATE_FORMAT(PrtTime,‘%i‘)  取分钟m

(h*60 m) /30          取整数部分进行分类汇总

Select result,count(result) as resultTotal,floor((DATE_FORMAT(PrtTime,‘%H‘) *60 DATE_FORMAT(PrtTime,‘%i‘))/30) as groupHalfHour from degassing_facility_production_data where (prtTime >= ‘2020-01-16‘ and prtTime < ‘2020-01-18‘) group by result,groupHalfHour ;