计算班上的学生排名? [英] Calculate student rank in class?

查看:71
本文介绍了计算班上的学生排名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一件事;我有一个表格,其中保存学生分数(StudentID,Marks)的值.假设有50个学生.我希望能够根据标记在表格上显示每个学生(分别是1st,2nd,3r ..... 50th)的班级排名.

我的想法:如果我加载了这些标记&通过使用带有ORDER BY(或什么?)的SELECT语句对数据集分配StudentID,我希望标记将以升序/降序排列,因此第一个在顶部,最后一个在底部.如果正确,那么我可以通过获取数据集中的行号来获得学生排名吗?
例如,在

Dataset.Tables("StudentRank").行(4).项目(2)

这适用于排名靠前/排名第5的学生.现在,如何获取.Rows(4)中包含的值并将其发布到某个地方或在任何地方使用它?

我希望我能很好地解释自己.

请给我任何帮助.

PS:我的意思是,如何知道数据集中记录的行号?我的主要观点是排名.

解决方案

如果只想显示,则使用gridview并按查询顺序进行排序.并从gridview索引号.


是的,您可以使用ORDER BY子句获取有序的学生排名列表.


报价:

dataset.Tables("StudentRank").行(4).项目(2)

这对我来说似乎正确.



报价:

PS:我的意思是,如何知道数据集中记录的行号?在DataTable中.记录号是行索引(据我所知,没有内部记录号).


请参见以下示例

 选择学生ID,标记, dense_rank()(顺序  by 标记 desc ) 作为的排名
来自
(
    选择  1   as  student_Id, 100  标记为
    联盟 全部
    选择  2  > as  student_Id, 100  标记为
    联盟 全部
    选择  3   as  student_Id, 80  标记为
)
 as  a 


祝您编码愉快!
:)


I want to ask one thing; I have a table where I keep values for students marks (StudentID,Marks). Let''s say there are 50 students. I want to be able to display on the form the class rank for each student (who is 1st,2nd,3r.....50th) according the marks.

MY IDEA: If I load these marks & studentID to a dataset by using a SELECT statement with ORDER BY (or what?), I hope the marks will be listed in an Ascending/Descending order, so the first at the top, the last at the bottom. If that''s correct, then can I obtain the student rank by obtaining his row number in the dataset?
For example, in

dataset.Tables("StudentRank").Rows (4).Item (2)

This will be for a student in rank/position 5 from the top. Now, how can I get the value contained in .Rows (4) and post it somewhere or use it anywhere?

I hope I explained myself well.

I will apreciate any help please.

PS: I mean, how can know the row number of a record in the dataset? My main point is ranking though.

解决方案

if you only want to display then use gridview and order by query. And from gridview index no. you got the rank.


Yes, you may use the ORDER BY clause to obtain the list of ordered student ranks.


Quote:

dataset.Tables("StudentRank").Rows (4).Item (2)

This looks correct to me.



Quote:

PS: I mean, how can know the row number of a record in the dataset?

Probably you meant the record number in a DataTable. The record number is the row index (as far as I know there is no intrinsic record number).


see this example

select student_Id,marks,dense_rank() over(order by marks desc) as Rank
from
(
    select 1 as student_Id, 100 as marks
    union all
    select 2 as student_Id, 100 as marks
    union all
    select 3 as student_Id, 80 as marks
)
as a


Happy Coding!
:)


这篇关于计算班上的学生排名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆