2011-09-07[sqlserver投票统计查询问题]

 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章