select macid, max(value) as 最大值,
(Select min(value) from biao) as 最小值,happentime as 最大值对应时刻 ,
(Select happentime from biao where value=min(value))as 最小值对应时刻
from biao
select macid,
(select max(value) from biao tmp1 ) as 最大值,
(select happentime from biao tmp2 where value=(select max(value) from biao tm1 )) as 最大值对应时刻,
(select min(value) from biao tmp3 ) as 最小值,
(select happentime from biao tmp4 where value=(select min(value) from biao tm2)) as 最小值对应时刻
from biao
错了,重贴,用以下语句
select macid,max(value) as 最大值,happentime as 最大值对应时刻,value as 最小值,happentime as 最小值对应时刻
from biao
where biao.value in (select max(value) from biao a union select min(b.value) from biao b)
group by value
用以下语句
select macid,max(value) as 最大值,happentime as 最大值对应时刻,value as 最小值,happentime as 最小值对应时刻
from biao
where biao.value in (select max(value) from biao union select min(value))
group by value
如果你的意思是最大值和最小值都放在同一条纪录中的话
我看可能不行吧,放在两条纪录中肯定没问题。
用
union
select macid,value as 最小值,happentime as 最小值对应时刻
from biao
where biao.value=(select min(value) from biao)