其中desc1为flag='1' 满足的description列
其中desc2为flag='2' 满足的description列
其中desc3为flag='3' 满足的description列

解决方案 »

  1.   

    select a.desc1,b.desc2,c.desc3 from
    (select description desc1 from a where flag='1') a,
    (select description desc2 from a where flag='2') b,
    (select description desc3 from a where flag='3') c;不知道这是不是LZ想要的
      

  2.   

    呀,搞错!
    我怎么跑到DB2里来了
    我本意是想到ORACLE的
    哈哈
    本人不懂DB2哈,是把此题当ORACLE来做的
    不知道DB2语法什么的有什么不同
    LZ 自己修改!
    搞笑,哈哈
      

  3.   

    select
    decode(flag, '1', description, null) as decs1
    decode(flag, '2', description, null) as decs2
    decode(flag, '3', description, null) as decs3
    from 
    a不知道这是楼主否是想要的结果.
      

  4.   

    SQL> insert into test_1 (col_1) select rownum from tab where rownum<4;3 rows insertedExecuted in 0.02 secondsSQL> commit;Commit completeExecuted in 0.04 secondsSQL> select * from test_1;     COL_1
    ----------
             1
             2
             3Executed in 0.35 secondsSQL> Select decode(col_1,1,col_1) As a,decode(col_1,2,col_1) As b,decode(col_1,3,col_1) As c From test_1;         A          B          C
    ---------- ---------- ----------
             1            
                        2 
                                   3Executed in 0.43 secondsSQL> Select a,b,c From (
      2         Select col_1 As a From test_1 Where col_1 ='1') x,
      3         (Select col_1 As b From test_1 Where col_1='2') y,
      4         (Select col_1 As c From Test_1 Where  col_1='3') z
      5  Where a Is Not Null
      6  And   b Is Not Null
      7  And   c Is Not Null
      8  /         A          B          C
    ---------- ---------- ----------
             1          2          3Executed in 0.08 seconds
      

  5.   

    谢谢大家的指教。
    nowait(独行天涯路) 
    你那种方式,我试了,如果col1=?的时候有满足的多条记录时,就会出现多余的行。
    我希望的结果是,结果的行数为各个查询记录的最大行数。
      

  6.   

    select
    decode(flag, '1', description, null) as decs1
    decode(flag, '2', description, null) as decs2
    decode(flag, '3', description, null) as decs3
    from 
    a
      

  7.   

    若满足条件:其中desc1为flag='1' 满足的列
              其中desc2为flag='2' 满足的列
              其中desc3为flag='3' 满足的列
    记录有多行,怎么来取列description的值?