注册 登录
编程论坛 ASP技术论坛

asp 学生成绩排名 SQL 写法

bichaoguo 发布于 2008-05-11 10:12, 1763 次点击
我有一个表 有考生姓名 name 字段 考生单科成绩chengji 字段
我希望考生登陆自己帐号的时候,能够看到自己排名
这个SQL 应该怎么写

非常感谢
<%
mUserName=Session("name")
set rs1=server.createobject("adodb.recordset")
sqlm="select(select count(*)from fyusercx where chengji>=a.chengji and fyuser1='"&mUserName&"') as mc * from fyusercx a

where fyuser1='"&mUserName&"'"

%>

你的总排名:<%=rs1("mc")%>

但是排名什么都不显示,为什么呢

请各位大哥帮忙!非常感谢
15 回复
#2
madpbpl2008-05-11 10:15
sqlserver数据库?
#3
bichaoguo2008-05-11 10:20
是的
#4
bichaoguo2008-05-11 10:21
表名是:fyusercx  考生姓名字段名是:fyuser1  考生成绩字段名是:chengji
#5
tianyu1232008-05-11 10:37
表的结构是什么样的?
#6
madpbpl2008-05-11 10:43
sqlm="select(select count(*)from fyusercx where chengji>=a.chengji and fyuser1='"&mUserName&"') as mc, * from fyusercx a

where fyuser1='"&mUserName&"'"
mc后面加个逗号试试,我这里没调试环境,不方便测试。
#7
bichaoguo2008-05-11 10:48
表的结构
表名是:fyusercx  这个表里的字段
考生姓名字段名是:fyuser1  
考生密码:password
考生成绩字段名是:chengji

就这样单一的一个表
#8
bichaoguo2008-05-11 10:49
显示的都是第一名
#9
bichaoguo2008-05-11 10:50
不对,怎么显示的都是第一名。
#10
madpbpl2008-05-11 10:53
sqlm="select(select count(*)from fyusercx where chengji>=a.chengji) as mc, * from fyusercx a

where fyuser1='"&mUserName&"'"
#11
bichaoguo2008-05-11 10:56
现在的问题是:
我输入5个考生的成绩:
考生姓名:  a   b   c    d     e  
考生考分    90  40  80   100   50

如果是正确的话,我用a 登陆应该总排名是 2 但是显示的确是1 .用e登陆显示的是3 怎么会有这样的错误呢
#12
bichaoguo2008-05-11 10:57
我现在用的就是这样的写法:
set rs1=server.createobject("adodb.recordset")
sqlm="select(select count(*)from fyusercx where chengji>=a.chengji ) as mc, * from fyusercx a where fyuser1='"&mUserName&"'"
#13
bichaoguo2008-05-11 10:58
用d 登陆的时候,显示第5名!
#14
madpbpl2008-05-11 11:41
和我想的有点象,错了一位,你再检查一下吧,我机子iis环境都没有
#15
bichaoguo2008-05-11 12:00
如果有相同的分数。就比如应该是并列第2名的,但是显示出来是并列第三名!
#16
bichaoguo2008-05-11 12:06
和我想的有点象,错了一位,你再检查一下吧,

这个应该怎么检查呀!

我看不出语句有什么不对的地方!
1