CREATE TABLE [dbo].[tb1]( [id] [int], [name] [varchar] (50), [course] [varchar] (50), [score] [int] )select id,[name],score from tb1 a order by (select min(score) from tb1 where [name]=a.[name]),score
汗!--? declare @1 TABLE ([id] int,[name] varchar(20),course varchar(20),score int) insert @1 select 1,'小明','语文',60 Union ALL select 1,'小明','数学',80 Union ALL select 1,'小明','英语',82 Union ALL select 2,'小李','数学',70 Union ALL select 2,'小李','英语',80 Union ALL select 2,'小李','语文',90select id,[name],score from @1 a order by 2 descid name score 1 小明 60 1 小明 80 1 小明 82 2 小李 70 2 小李 80 2 小李 90
发错declare @1 TABLE ([id] int,[name] varchar(20),course varchar(20),score int) insert @1 select 1,'小明','语文',60 Union ALL select 1,'小明','数学',80 Union ALL select 1,'小明','英语',82 Union ALL select 2,'小李','数学',70 Union ALL select 2,'小李','英语',80 Union ALL select 2,'小李','语文',90select id,[name],score from @1 a order by 2 desc ,3
declare @1 TABLE ([id] int,[name] varchar(20),course varchar(20),score int)
insert @1
select 1,'小明','语文',60 Union ALL
select 1,'小明','数学',80 Union ALL
select 1,'小明','英语',82 Union ALL
select 2,'小李','数学',70 Union ALL
select 2,'小李','英语',80 Union ALL
select 2,'小李','语文',90select id,[name],score
from @1 a
order by 2 descid name score
1 小明 60
1 小明 80
1 小明 82
2 小李 70
2 小李 80
2 小李 90
insert @1
select 1,'小明','语文',60 Union ALL
select 1,'小明','数学',80 Union ALL
select 1,'小明','英语',82 Union ALL
select 2,'小李','数学',70 Union ALL
select 2,'小李','英语',80 Union ALL
select 2,'小李','语文',90select id,[name],score
from @1 a
order by 2 desc ,3