有表t,字段a、b、c
要取记录distinct a, min(b), max(c)

解决方案 »

  1.   

    select distinct a, min(b), max(c) from t  group by a
      

  2.   

    为什么要group by?这样就是楼主的意思啦!
    select distinct a, min(b), max(c) from t
      

  3.   

    不好意思,应该这样。
    select distinct a, b, c
    from t
    where b in (select b from t where b in (select min(b) from t)) 
       or c in (select c from t where c in (select max(c) from t))
      

  4.   

    select distinct a, b, c
    from t
    where b = (select min(b) from t t1 where t1.a = t.a)
    and c = (select max(c) from t t2 where t.a = t2.a and t.b = t2.b) 
    不知道这种方法是否正确,请高手指正。
      

  5.   

    可以 在PL/SQL里面执行(调试)下不就出来了么
      

  6.   

    000
    001
    012
    100
    101
    112
    我想取的是:
    001
    101
    而非
    002
    102你不是说要max(c)吗? max(c)就是2阿
      

  7.   


      1  select a,b,max(c) from(
      2  select a.a,b.b,a.c from test a,(select min(b) b from test) b where a.b=b.b)
      3* group by a,b
    SQL> /         A          B     MAX(C)
    ---------- ---------- ----------
             0          0          1
             1          0          1