mysql 分组查询的结果当成临时表 在求最大值

select avg(data1) as a from temp WHERE YEAR(mdate)= 2018 and MONTH(mdate)=03 and day(mdate)=25 GROUP BY hour(mdate);

6 6 10 9 10 11 10 14 17 18 19 20 23 22 23 20 21 19 18 18 17 13 12 10

select MAX(s.a) from (select avg(data1) as a from temp WHERE YEAR(mdate)= 2018 and MONTH(mdate)=03 and day(mdate)=25 GROUP BY hour(mdate)) s;

23

posted @ 2018-04-03 22:47  zhaocundang  阅读(535)  评论(0编辑  收藏  举报