将下面样式的
A    B    C
77  88    99转换成Name    Value
A        77
B        88
C        99寻求简单的sql语句,union all格式的太多了。

解决方案 »

  1.   

    哪位帮忙解决下吗?我的sql是外行
      

  2.   

    你就只有一行三列的数?如果只有这么点,union吧,其它方法更麻烦
      

  3.   

    是啊,只有一行三列,请问decode能解决吗
      

  4.   

    decode只能针对数据,无法针对列名啊
      

  5.   

    列转行,用UNION是最简单的方法
    DECODE是行转列
      

  6.   

    结合视图user_tab_column能行吗?说明
    A    B    C 
    77  88    99该结果不是通过子查询查出的,即
    select 
        sum(s.cjs) as cjs , sum(s.jyfjf) as jyfjf, sum(s.dfjyfj) as dfjyfj
    from
      (select
    n.nsrsbm
       from
    (select ys_dm from city_level) s
    inner join nsr_jc n on s.ys_dm = n.skzh_id
       ) m, ssbd s
    where m.nsrsbm = s.nsrsbh
      

  7.   

    SQL2005 :
    --------------------------------------------
    create table aaa(a int,b int ,c int)insert into aaa values(77,88,99)select * from aaa
    unpivot (vaa for bb in ([a],[b],[c])) as pvtdrop table aaa-------------------------------------------
      

  8.   

    不明白什么意思。我的是oracle10, 试着用了下你的语句,通不过