老师好:关于并列名次,请教如何实现(参考其它例子,但是结果效果却不一样)
Dim pcs As List(Of String) = DataTables("进出分析").GetValues("计算")
For Each pc As String In pcs
Dim drs As List(Of DataRow) = DataTables("进出分析").Select("[计算] = '" & pc & "'", "批次 DESC")
For n As Integer = 0 To drs.Count - 1 '遍历所有行
If n > 0 AndAlso drs(n)("批次") = drs(n-1)("批次") Then '如果批次和上一行相同
drs(n)("批次排名") = drs(n-1)("批次排名") '则批次排名等于上一行
Else
drs(n)("批次排名") = n + 1 '设置批次排名
End If
Next
Next
Dim pcs1 As List(Of String) = DataTables("进出分析").GetValues("计算")
For Each pc1 As String In pcs1
Dim drs1 As List(Of DataRow) = DataTables("进出分析").Select("[计算] = '" & pc1 & "'", "采购数量 DESC")
For n1 As Integer = 0 To drs1.Count - 1 '遍历所有行
If n1 > 0 AndAlso drs1(n1)("数量排名") = drs1(n1-1)("数量排名") Then '如果名次和上一行相同
drs1(n1)("数量排名") = drs1(n1-1)("数量排名") '则名次排名等于上一行
Else
drs1(n1)("数量排名") = n1 + 1 '设置批次排名
End If
Next
Next
计算显示错误效果

此主题相关图片如下:并列名次.jpg

谢谢!
已参考:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&replyID=475518&ID=69207&skin=1
[此贴子已经被作者于2019/11/13 10:56:45编辑过]