oracle实现按天查询最大值、最小值、平均值
主要用到的函数
- MAX()最大值
- MIN()最小值
- SVG()平均值
- round()截取小数点后几位
- to_number()将字符串类型转数字类型
SELECT ps.device_intenet_num,to_char(ps.uploadtime, 'yyyy-mm-dd') as uploadtime,MAX(to_number(ps.firstcurrentvalue)),MIN(to_number(ps.firstcurrentvalue)),MAX(to_number(ps.firsttemperaturevalue)),
round(avg(ps.firstcurrentvalue),2)
FROM pw_smdevicedata ps
where device_intenet_num='177-1'
GROUP BY to_char(ps.uploadtime, 'yyyy-mm-dd'),ps.device_intenet_num
ORDER BY uploadtime;