http://community.csdn.net/Expert/topic/4161/4161213.xml?temp=.1366846
你自己看看吧,再修改一下就行了。

解决方案 »

  1.   

    SQL> select * from aa;        ID     TESTID      SCORE
    ---------- ---------- ----------
             1          1         66
             1          2         67
             2          1         69
             2          3         60
             2          2         61
             2          4         62
             2          5         63
             3          1         64
             3          3         65
             3          4         99
             3          7         88已选择11行。select id,
           min(decode(1,latest_3,score,''))||
           min(decode(2,latest_3,','||score,''))||
           min(decode(3,latest_3,','||score,'')) result from (
    select id,
           score,
           row_number() over (partition by id order by testid desc nulls last) latest_3
    from   aa )
    group  by id        ID RESULT
    ---------- ------------------------------
             1 67,66
             2 63,62,60
             3 88,99,65SQL>
      

  2.   

    ATGC(想到南极去看看飞翔的海鸥):
    多谢了,分组后用MIN函数这部分看不太懂。能否介绍一下思想?