create table tb(ID int,polls int,namevarchar(10))
insert into tbvalues(1 ,2 ,'張三')
insert into tbvalues(2 ,9 ,'李四')
insert into tbvalues(3 ,0 ,'王五')
insert into tbvalues(4 ,2 ,'趙六')
insert into tbvalues(5 ,2 ,'周七')
insert into tbvalues(6 ,8 ,'周潤發')
insert into tbvalues(7 ,9 ,'張國榮')
go
select * , 排名= (selectcount(distinct polls)from tbwhere polls>= t.polls)from tb t orderby 排名
drop table tb