select dt.cellno, dt.bin
from dt join ts on dt.s_id=ts.s_id and dt.ww=ts.ww
where ts.ww=27
and ts.sta=2971
and dt.m_id='CCD01STH04TS01'
order by dt.cellno现在搜索出一组数据 如下:
CELL11 6222
CELL11 100
CELL11 100
CELL11 100
CELL11 100
CELL11 100
CELL11 100
CELL11 100
CELL11 100
CELL12 6201
CELL12 6201
CELL12 6201
CELL12 6201
CELL12 6201
CELL12 6201
CELL12 6201
CELL13 100
CELL13 100
CELL13 100
CELL13 100
CELL13 100
CELL13 9800
CELL13 100
CELL13 100
但我想将其按 CELL NO 分类排列,改怎么写呢?cell11   6222 100  100  100  100  100
cell12   6201 6201 6201 6201
cell13   100  100  100  100  100  9800 100  100

解决方案 »

  1.   

    select cellno,replace(wm_concat(bin),',',' ')
    from (
          select dt.cellno, dt.bin
          from dt join ts on dt.s_id=ts.s_id and dt.ww=ts.ww
          where ts.ww=27
          and ts.sta=2971
          and dt.m_id='CCD01STH04TS01'
          order by dt.cellno)
    group by cellno
      

  2.   

    Oracle 10g可以用wm_concat函数,如一楼!
      

  3.   

    可以参考paddy的博客
    http://blog.csdn.net/gelyon/archive/2010/09/20/5897608.aspx
      

  4.   


    select name,wm_concat(bin)
    from dt join ts on dt.s_id=ts.s_id and dt.ww=ts.ww
    where ....
    group by no