34,874
社区成员
发帖
与我相关
我的任务
分享
create table #t
(
A int,
B int,
C int
)
insert into #t
select 1,1,1 union all
select 1,2,0 union all
select 1,3,1 union all
select 1,4,0
select * from #t
union all
select * from #t where C = 0
order by B,C

create table #t
(
A int,
B int,
C int
)
insert into #t
select 1,1,1 union all
select 1,2,0 union all
select 1,3,1 union all
select 1,4,0
go
insert into #t
select * from #t where C =0
go
select * from #t
ORDER BY b,c
/*
A B C
----------- ----------- -----------
1 1 1
1 2 0
1 2 0
1 3 1
1 4 0
1 4 0
*/借用一下早恋的代码,其实5楼已经写出来了
INSERT INTO #t SELECT * FROM #t where C=0
SELECT * from #t ORDER BY B,C
create table #t
(
A int,
B int,
C int
)
insert into #t
select 1,1,1 union all
select 1,2,0 union all
select 1,3,1 union all
select 1,4,0
go
insert into #t
select * from #t where C =0
go
select * from #t