Select * From (Select TOP 100 Percent * From TableName Where 平均年龄>10 Order By 平均年龄) A Union All Select * From (Select TOP 100 Percent * From TableName Where 平均年龄<10 Order By 平均年龄) A
if object_id('test') is not null drop table test select 1 as 年级, 11 as 平均年龄 into test union select 3, 13 union select 4, 14 union select 2, 12 union select 2, 2 union select 4, 4 union select 1, 1 union select 3, 3 ------------------------------------- select * from test order by 平均年龄/10 desc, 平均年龄 /* 年级 平均年龄 1 11 2 12 3 13 4 14 1 1 2 2 3 3 4 4 */ ------------------------------------- drop table test
select * from test order by len(cast(平均年龄 as varchar)) desc, 平均年龄
(Select TOP 100 Percent * From TableName Where 平均年龄>10 Order By 平均年龄) A
Union All
Select * From
(Select TOP 100 Percent * From TableName Where 平均年龄<10 Order By 平均年龄) A
select 1 as 年级, 11 as 平均年龄
into test
union select 3, 13
union select 4, 14
union select 2, 12
union select 2, 2
union select 4, 4
union select 1, 1
union select 3, 3
-------------------------------------
select *
from test
order by 平均年龄/10 desc, 平均年龄
/*
年级 平均年龄
1 11
2 12
3 13
4 14
1 1
2 2
3 3
4 4
*/
-------------------------------------
drop table test
from test
order by len(cast(平均年龄 as varchar)) desc, 平均年龄