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

来源:互联网 发布:debian修改软件源 编辑:程序博客网 时间:2024/05/19 16:23

 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

原创粉丝点击