
---
#领域/物联实验室 

#复盘/0 #临时/备忘

## 一句话描述

[___Dataease 配置数据集_____]

---

本周人流量
```mysql
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;
```

今日人流量
```mysql
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;
```

环境平均
```mysql
SELECT
  DATE_FORMAT(Time, '%y/%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;
```

环境
```mysql
select * from env order by id desc limit 1;
```

行为数据
```mysql
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;
```
