select distinct id, (select min(time) table1 b where status=10 and b.id=a.id) as MINTIME   
,(select max(time) table1 c where status=11 and c.id=a.id) as MAXTIME     from table1 a

解决方案 »

  1.   

    select distinct id, (select min(time) from  table1 b where status=10 and b.id=a.id) as MINTIME   
    ,(select max(time) from table1 c where status=11 and c.id=a.id) as MAXTIME     from table1 a
      

  2.   

    select distinct id, max(time) ,min(time) from 表名 group by id
      

  3.   

    select id, max(time) as MINTIME ,min(time) as MAXTIME from 表名 group by id