在sqlplus中可以这样显示,使用一个设置就可以了,但是在程序中我没有试过,不过好象roolup或者cube好象可以做,具体你查查相关的帮助吧。

解决方案 »

  1.   

    你再改改
    SQL> select * from ttt
      2  /NAME          VAL
    ---------- ------
    吴              1
    吴              2
    吴              3
    张              2
    张             11
    张             216 rows selectedSQL> select decode(b.rowname,
      2                (select min(dd)
      3                   from (select t.*, rownum dd from ttt t) c
      4                  where c.name = b.name),
      5                b.name,
      6                ''),
      7         b.val
      8    from (select t.*, rownum rowname from ttt t) b
      9  /DECODE(B.ROWNAME,(SELECTMIN(DD    VAL
    ------------------------------ ------
    吴                                  1
                                        2
                                        3
    张                                  2
                                       11
                                       216 rows selected
      

  2.   

    select a.xh,decode((select min(xh) from table where num=a.num),a.xh,a.num,null) num, su,yy,bz from table a
      

  3.   

    SQL> select no,q,date1 from test;NO            Q DATE1
    ---------- ---- -----------
    001           5 2005-7-14
    001           5 2005-7-15
    001           5 2005-7-16
    001           5 2005-7-17
    001           5 2005-7-18
    002           6 2005-7-17
    003           4 2005-7-13
    003           4 2005-7-14
    003           4 2005-7-15
    003           4 2005-7-16
    003           4 2005-7-17
    003           4 2005-7-1812 rows selectedselect decode(rn,1,no,'') no,decode(rn,1,q,'') no,date1 from 
    (select t.*,row_number() over(partition by no,q order by date1) rn 
    from test t
    )SQL> 
      5  /NO                 NO DATE1
    ---------- ---------- -----------
    001                 5 2005-7-14
                          2005-7-15
                          2005-7-16
                          2005-7-17
                          2005-7-18
    002                 6 2005-7-17
    003                 4 2005-7-13
                          2005-7-14
                          2005-7-15
                          2005-7-16
                          2005-7-17
                          2005-7-1812 rows selected
      

  4.   

    在此首先感谢guangli_zhang(广丽) ,昨天已经搞定了再感谢其他在场的各位