select [a]=a1,名称,金额 from tb
union all
select [a]=a2,名称,金额 from tb
union all
select [a]=a3,名称,金额 from tb

解决方案 »

  1.   

    --测试环境
    declare @表A table (a1 varchar(10),a2 varchar(10),a3 varchar(10),名称 varchar(20),金额 money)
    insert into @表A select 'aaa','bbb','ccc','上市公司',300--查询
    select a1,名称,金额 from @表A
    union all
    select a2,名称,金额 from @表A
    union all
    select a3,名称,金额 from @表A
    --结果
    a1         名称                   金额                    
    ---------- -------------------- --------------------- 
    aaa        上市公司                 300.0000
    bbb        上市公司                 300.0000
    ccc        上市公司                 300.0000(所影响的行数为 3 行)
      

  2.   

    Create View 视图名
    as
    select a1,名称,金额 from @表A
    union all
    select a2,名称,金额 from @表A
    union all
    select a3,名称,金额 from @表A
      

  3.   

    Create View 视图名
    as
    select a1,名称,金额 from @表A
    union all
    select a2,名称,金额 from @表A
    union all
    select a3,名称,金额 from @表A
      

  4.   

    为什么我在zlp的测试环境中,测试不成功的呢,要我声明变量@表A!!奇怪