juechafun/Untitled.md

1.4 KiB


#复盘/0 #临时/备忘 #状态/待处理

20260205-备忘-主题名-文件内容

一句话描述

[________]


本周

select sum(InNum) as InNum, sum(OutNum) as OutNum from (SELECT
	DATE_FORMAT( DataDateTime, '%m%d' ) AS MonthDay,
	max( InNum ) AS InNum,
	max( OutNum ) AS OutNum
FROM
	people
WHERE
	1 and DataDateTime >= DATE_SUB(CURDATE(),INTERVAL 7 DAY)
GROUP BY
	MonthDay
ORDER BY
MonthDay DESC) as _week_people;

今日

SELECT
	DATE_FORMAT( DataDateTime, '%m%d' ) AS MonthDay,
	max( InNum ) AS InNum,
	max( OutNum ) AS OutNum
FROM
	people
WHERE
	1  and DataDateTime >= DATE_SUB(CURDATE(),INTERVAL 1 DAY)
GROUP BY
	MonthDay
ORDER BY
MonthDay DESC limit 1;

环境平均

SELECT
  DATE_FORMAT(Time, '%m/%d') AS month_day,
  AVG(Temperature) AS Temperature,
	AVG(Humidity) AS Humidity,
	AVG(TVOC) AS TVOC,
	AVG(eCO2) AS eCO2,
	AVG(PM10) AS PM10,
	AVG(PM2_5) AS PM2_5
FROM
  env
GROUP BY
  month_day 
ORDER BY
  month_day desc limit 30;

环境

select * from env order by id desc limit 1;

行为数据

SELECT * from (

select * from (SELECT
	DataDateTime,
	"人流经过" AS 行为
FROM
	people
WHERE
	 type = '1' order by DataDateTime desc) as t1

	UNION ALL

	select * from (SELECT `datetime`, `msg` from log where `msg`!='物联控制' and `msg`!="") as t2
) as t1_2 ORDER BY DataDateTime desc limit 20;