论坛: 编程破解 标题: 查器械库温湿度的SQL语句(原创) 复制本贴地址    
作者: SCANDISK [scandisk]    论坛用户   登录
SELECT
date_format( `data_home`.`devtime`, '%m %d %H' ) AS `时间`,
`data_home`.`terminalname` AS `测点`,
round( avg( `data_home`.`temperature` ), 1 ) AS `温度`,
round( avg( `data_home`.`humidity` ), 1 ) AS `湿度`
FROM
`data_home`
WHERE
((
`data_home`.`devtime` >= '2021-08-20 00:00:00'
)
AND ( `data_home`.`terminalname` LIKE '%理货间1%' )
AND ((
HOUR (
cast( `data_home`.`devtime` AS time )) LIKE '%10%'
)
OR ( HOUR ( cast( `data_home`.`devtime` AS time )) LIKE '%15%' ))
AND ( cast( `data_home`.`devtime` AS time ) >= '10:30:00' )
AND ( cast( `data_home`.`devtime` AS time ) <= '15:30:00' ))
GROUP BY
`时间`,
`测点`

//以上代码在MYSQL 5.7中执行通过!(导航猫12.1.25),功能:查每天上午10点和下午5点的平均温湿度。





[此贴被 SCANDISK(scandisk) 在 09月13日07时18分 编辑过]

地主 发表时间: 21-09-13 07:12

论坛: 编程破解

20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon

粤ICP备05087286号