我原先的SQL是这样的:
select t1.time,max(apac) as mpac from (select time,avg(Pac) as apac from A where time>="2017-09-20" and time<="2017-10-30" group by time) t1 group by DATE_FORMAT(time,"%Y-%m-%d");
可是这样查询出来的时间不对,是分组后每天的开始时间
我应该怎么改
3 个解决方案
#1
select *
from A a1
where not exits (select 1 from A a2 where date(a1.time)=date(a2.time) and a1.siteid<a2,siteid )
order by a1.time desc;
#2
a1,a2是什么东西啊,买看明白
#3
a1,a2是表的别称,因为要连续用两次A表,所以要起个别称a1,a2,来区分
#1
select *
from A a1
where not exits (select 1 from A a2 where date(a1.time)=date(a2.time) and a1.siteid<a2,siteid )
order by a1.time desc;
#2
select *
from A a1
where not exits (select 1 from A a2 where date(a1.time)=date(a2.time) and a1.siteid<a2,siteid )
order by a1.time desc;
a1,a2是什么东西啊,买看明白
#3
select *
from A a1
where not exits (select 1 from A a2 where date(a1.time)=date(a2.time) and a1.siteid<a2,siteid )
order by a1.time desc;