create or replace view laview as
select 
 sum(decode(opid,'time D',1,0))time,
 sum(decode(opid,'compId',1,0))compid,
 sum(decode(opid,'alarmType',1,0))alarmtype,
 sum(decode(opid,'severity',1,0))serverity,
 sum(decode(opid,'probableCause',1,0))probaleC
 from table;
得出的值为什么是0 ?
table里的数据
OPID                           ALATEXT
---------------------------------------------------------
time D                         2006 09 07 15 43 51
compId                         NI EM HBJMPP04 LP 2 E1 23
alarmType                      E communications
severity                       E minor
probableCause                  E degradedSignal

解决方案 »

  1.   

    我模拟了lz的数据,查询很正常呀,我的是9I,在PLSQL Developer7.0测试的,建议LZ
    select * from table where OPID ='time D'试试
      

  2.   

    其实我是想转换成这样
    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
      

  3.   

    经过测试.数据显示正常.你查询还正常啊?这是一个将某列转成某行的例子
    select substr(max(sys_connect_by_path(userid,',')),2) A1
    from (select userid,rownum rn from zzb_userposthis)
    start with rn = 1
    connect by rn = prior rn+1
      

  4.   

    create or replace view laview as
    select 
     sum(decode(opid,'time D',ALATEXT,' '))time,
     sum(decode(opid,'compId',ALATEXT,' '))compid,
     sum(decode(opid,'alarmType',ALATEXT,' '))alarmtype,
     sum(decode(opid,'severity',ALATEXT,' '))serverity,
     sum(decode(opid,'probableCause',ALATEXT,' '))probaleC
    from table;
    /
      

  5.   

    select 
    (select ALATEXT from table where poid='time D') time,
    (select ALATEXT from table where opid='compId') compid,
    (select ALATEXT from table where opid='alarmType') alarmtype,
    (select ALATEXT from table where opid='severity') serverity,
    (select ALATEXT from table where opid='probableCause') probaleC
    from dual
      

  6.   

    行列转换的问题。请楼主看看这个帖子
    http://community.csdn.net/Expert/topic/5000/5000557.xml?temp=.5728113