数据库的结构
1
2
3
4
5
6
7
8
变成
1 5
2 6
3 7
4 8

解决方案 »

  1.   

    declare @T table(id int)
    insert into @T select 1
    union all select 2
    union all select 3
    union all select 4
    union all select 5
    union all select 6
    union all select 7
    union all select 8select convert(char,a.id) + ' ' + convert(char,b.id) as aaa
    from @T a,@T b
    where a.id<5 and b.id>4 and 
    a.id=b.id-4
      

  2.   

    create table AB(a int)
    insert into ab values(1)
    insert into ab values(2)
    insert into ab values(3)
    insert into ab values(4)
    insert into ab values(5)
    insert into ab values(6)
    insert into ab values(7)
    insert into ab values(8)
    create view m
    as
    select max(a) a,min(a) b
    from ab
    group by a%4select * from m order by  a