select 第一列 from table
union all
select 第二列 from table
...

解决方案 »

  1.   

    表1
    A       B
    1       31
    2       34
    3       25
    4       65
    .       .
    .       .  
    表2
    1     2     3     4   ...
    31    34    25    65  ...将表1转化为表2的形式
    用SQL 语句如何写
    在线等待!!!
      

  2.   

    select
    sum(case A when 1 then B else 0 end) as 1
    sum(case A when 2 then B else 0 end) as 2
    sum(case A when 3 then B else 0 end) as 3
    sum(case A when 4 then B else 0 end) as 4
    .
    .
    . into 表2
    from 表1
      

  3.   

    insert into 表2
    select
    sum(case A when 1 then B else 0 end) as 1
    sum(case A when 2 then B else 0 end) as 2
    sum(case A when 3 then B else 0 end) as 3
    sum(case A when 4 then B else 0 end) as 4
    .
    .
    from 表1