数据库内有表  table1   表内有字段time , aaa字段  格式如下 time             aaa   
10:01            22
10:02            34
10:03            43
10:04            44
10:05            44
10:06            32
10:07             5
10:08            32
10:10            33
10:11            100
...................
15:20          236时间是连续的且再更新,在查询的那一时刻判断aaa的值是不是aaa内所有数据最大值或最小值  ,是则找出这个时间

解决方案 »

  1.   

    select * from table1 order by aaa desc limit 1
      

  2.   

    不知道你说的是不是这个意思select  time from tab where aaa in (select max(aaa) ,min(aaa) from tab) and time = now()
      

  3.   

    select * from table1 order by aaa desc limit 1 这个可以选出最大值,再帮忙看看怎么选出最小值,时间没有啊不知道你说的是不是这个意思select time from tab where aaa in (select max(aaa) ,min(aaa) from tab) and time = now()
    这个执行不了,不知道为什么啊
      

  4.   

    select * from table1 a 
    where not exists (select 1 from table1 where aaa<a.aaa)
    or not exists (select 1 from table1 where aaa>a.aaa)