declare @t table(a varchar(10)) insert into @t select 'aa' insert into @t select 'vd' insert into @t select 'gr' insert into @t select 're' insert into @t select 'bb' insert into @t select 'other'select * from @t order by case a when 'other' then (select max(a)+'1' from @t) else a end--这样?
这样行不? select * into #temp from table_name where type<>'other' order by type select * from #temp union all select * from table_name where type='other'
Select * From @t Order By Case type When 'other' Then 1 Else 0 End,type不用再計算一次啊。
declare @t table(a varchar(10)) insert into @t select 'aa' insert into @t select 'vd' insert into @t select 'gr' insert into @t select 're' insert into @t select 'other' insert into @t select 'bb'--放在最前面 select * from @t order by case a when 'other' then char(0) else a end --放在最后面 select * from @t order by case a when 'other' then char(255) else a end
insert into @t select 'aa'
insert into @t select 'vd'
insert into @t select 'gr'
insert into @t select 're'
insert into @t select 'bb'
insert into @t select 'other'select * from @t order by case a when 'other' then (select max(a)+'1' from @t) else a end--这样?
select * into #temp from table_name where type<>'other' order by type
select * from #temp
union all
select * from table_name where type='other'
insert into @t select 'aa'
insert into @t select 'vd'
insert into @t select 'gr'
insert into @t select 're'
insert into @t select 'other'
insert into @t select 'bb'--放在最前面
select * from @t order by case a when 'other' then char(0) else a end
--放在最后面
select * from @t order by case a when 'other' then char(255) else a end
这个什么意思?