ID   快递单号   快递单价格   回单号  回单价格
 1      001       10          1201     3
 这类数据,怎么变成
id    number  price
 1     001     10
 1     1201    3
的格式
    

解决方案 »

  1.   


    select id,快递单号 as a,快递单价格 as b from tb
    union all
    select id,回单号,回单价格 from tb
    order by id
      

  2.   

    select ID, 快递单号, 快递单价格 from T
    union
    select ID ,回单号, 回单价格  from T
      

  3.   

    select ID, 快递单号, 快递单价格 from tb 
    union
    select ID ,回单号, 回单价格  from tb
      

  4.   

    /*
    ID 快递单号 快递单价格 回单号 回单价格
     1 001 10 1201 3
    这类数据,怎么变成
    id number price
     1 001 10
     1 1201 3
    */go
    if OBJECT_ID('tbl') is not null
    drop table tbl
    go
    create table tbl(
    ID int,
    快递单号 varchar(10),
    快递单价格 numeric(10,2),
    回单号 varchar(10),
    回单价格 numeric(10,2)
    )
    insert tbl
    select 1,'001',10,1201,3select id,快递单号 as number,快递单价格 as price from tbl
    union all
    select id,回单号,回单价格 from tbl/*
    id number price
    1 001 10.00
    1 1201 3.00
    */