網上很多版本都是錯的.
代码
create table #tb1([Name] nvarchar(20),score int)
insert into #tb1
select 'studentA',90 union all
select 'studentB',90 union all
select 'studentC',90 union all
select 'studentD',85 union all
select 'studentE',80 union all
select 'studentF',80 union all
select 'studentG',80 union all
select 'studentH',75 union all
select 'studentI',70 union all
select 'teacherA',90 union all
select 'teacherB',85
go
select * from #tb1 where [Name] like 'student%'
go
select top 5 * from #tb1 where [Name] like 'student%' order by score desc
go
select top 5 with ties * from #tb1 where [Name] like 'student%' order by score desc

浙公网安备 33010602011771号