--数据如下
create table #a([A] int,[B] int)
go
insert into #a
SELECT 1,2 UNION
SELECT 2,6 UNION
SELECT 3,5 UNION
SELECT 4,3 UNION
SELECT 5,4select * from #a
select * from #a order by A descdrop table #a--如何得到下表 (就是把第二个表里的内容,直接拼到第一个表的后面。)
A B A2 B2
------------------------------
1 2 5 4
2 6 4 3
3 5 3 5
4 3 2 6
5 4 1 2
create table #a([A] int,[B] int)
go
insert into #a
SELECT 1,2 UNION
SELECT 2,6 UNION
SELECT 3,5 UNION
SELECT 4,3 UNION
SELECT 5,4select * from #a
select * from #a order by A descdrop table #a--如何得到下表 (就是把第二个表里的内容,直接拼到第一个表的后面。)
A B A2 B2
------------------------------
1 2 5 4
2 6 4 3
3 5 3 5
4 3 2 6
5 4 1 2
解决方案 »
- 欲哭无泪,误删数据,请帮忙,在线等...
- |zyciis| 麻烦帮我发析一下,我手写的SQL和NHibernate生成的SQL的性能相差有多远
- 请问with(xlock,锁)和with(锁)效果一样吗
- 有很多记录 怎样统计最后一条记录 在所有的记录中连续出现最多的次数
- 一些有讨论价值的语句,高手请进
- 这样的查询语句怎么写啊?
- BUILTIN\ADMINISTRATORS禁了,sa密码忘了,怎么办呀???
- 面试常问的SQL题目,请各抒己见
- sql server ce是不是没存储过程的?
- 我的数据库标为“紧急模式” ,如何解决
- 这也算是一个Bug吗?
- 听说游标feth一次就等于select了一次?
go
insert into #a
SELECT 1,2 UNION
SELECT 2,6 UNION
SELECT 3,5 UNION
SELECT 4,3 UNION
SELECT 5,4select *,id=identity(int,1,1) into # from #aselect *,id=identity(int,1,1) into #t from #a order by A descselect a.a,a.b,b.a as a2,b.b as b2
from # as a full join #t as b on a.id=b.iddrop table #a
drop table #
drop table #t
/*
a b a2 b2
----------- ----------- ----------- -----------
1 2 5 4
2 6 4 3
3 5 3 5
4 3 2 6
5 4 1 2
*/
select * from #a
Union all
select * from #a order by A desc
[\sql]
可以放下面,放后面就不知道了,或许需要建一个空表吧,类型要匹配