OPID                           ALATEXT
 
time                        2006 09 07 15 43 51
comp                        NI E  LP 2 E1 23
Type                        E coations
severity                    E mi
probable                    E deSignal想转换成
  time                  comp              Type        severity   probable
 2006 09 07 15 43 51  NI E  LP 2 E1 23   E coations    E mi     E deSignal请问该怎么办?

解决方案 »

  1.   

    select time,...,probable,count(*)
    from
     (select decode(OPID,'time',ALATEXT) as time,
     ...,
     decode(probable,'time',ALATEXT) as probable  
     from tab)
    group by time,...,probable之后再嵌掏一层,把count(*)去掉!
      

  2.   

    select  decode(OPID,'time', ALATEXT,null) time,
            decode(OPID,'comp', ALATEXT,null) comp
            decode(OPID,'type', ALATEXT,null) type
            decode(OPID,'severity', ALATEXT,null) severity
            decode(OPID,'probable', ALATEXT,null) probable
      from  table 
     group  by OPID
      

  3.   

    楼主,只有一条纪录吗?这样看看
    select  decode(OPID, 'time', select time from table, null) time,
            decode(OPID, 'comp', select comp from table, null) comp
            decode(OPID, 'type', select type from table, null) type
            decode(OPID, 'severity', select severity from table, null) severity
            decode(OPID, 'probable', select probable from table, null) probable
      from  table 
     group  by OPID
      

  4.   

    稍微修改一下:
    select time,...,probable,count(*)
    from
     (select decode(OPID,'time',ALATEXT) as time,
     ...,
     decode(OPID,'probable',ALATEXT) as probable  
     from tab)
    group by time,...,probable
      

  5.   

    那你先試試子查询是否可以取得值:
    select decode(OPID,'time',ALATEXT) as time,
     ...,
     decode(OPID,'probable',ALATEXT) as probable  
     from tab
      

  6.   

    子查询应该取到如下格式的值:
      time                comp               Type          severity   probable
      2006 09 07 15 43 51  
                          NI E  LP 2 E1 23   
                                             E coations    
                                                           E mi
                                                                      E deSignaltime                        2006 09 07 15 43 51
    comp                        NI E  LP 2 E1 23
    Type                        E coations
    severity                    E mi
    probable                    E deSignal
      

  7.   

    感谢各未的回答,但是还是不行,我用select decode(OPID,'time',ALATEXT)这句查询的话也是什么都没有。
    我的表里数据是这样的:
    OPID                           ALATEXT
     
    time                        2006 09 07 15 43 51
    comp                        NI E  LP 2 E1 23
    Type                        E coations
    severity                    E mi
    probable                    E deSignal
    time                        2006 09 08 10 40 50
    comp                        NI E  LP 2 E1 23
    Type                        E coationsss
    severity                    E mirrr
    probable                    E deSignalwww想转换成
      time                  comp              Type        severity   probable
     2006 09 07 15 43 51  NI E  LP 2 E1 23   E coations    E mi     E deSignal
      

  8.   

    select  decode(OPID, 'time', select ALATEXT from table where OPID = 'time', null) time,
            decode(OPID, 'comp', select ALATEXT from table where OPID = 'comp', null) comp
            decode(OPID, 'type', select ALATEXT from table where OPID = 'type', null) type
            decode(OPID, 'severity', select ALATEXT from table where OPID = 'severity', null) severity
            decode(OPID, 'probable', select ALATEXT from table where OPID = 'probable', null) probable
      from  table 
     group  by OPID