590
社区成员
发帖
与我相关
我的任务
分享
-- 给你写个例子,你研究一下
create table test(id int, name varchar(10), num int)
go
insert into test values(1,'china',3),(2,'beijing',2),(3,'hebei',4)
go
select t.*
from test t
inner join master..spt_values s on t.num > s.number
where s.type = 'p'
order by id
go
drop table test
go
(3 行受影响)
id name num
----------- ---------- -----------
1 china 3
1 china 3
1 china 3
2 beijing 2
2 beijing 2
3 hebei 4
3 hebei 4
3 hebei 4
3 hebei 4
(9 行受影响)
;WITH 表A(ID,D1,D2)AS(
select 1,'小明','自行车' union all
select 2,'小芳','汽车'
)
SELECT * FROM (
SELECT *
FROM 表A
UNION ALL
SELECT *
FROM 表A)t
ORDER BY t.ID
select * from table1
union all
select * from table1
order by d1