以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 等级划分漏统数据如何处理 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=160595) |
-- 作者:lzzhyl001 -- 发布时间:2021/2/7 18:04:00 -- 等级划分漏统数据如何处理 在foxtable的安装目录CaseStudy下有一个“等级划分”示例文件,表中有分数和等级两列,根据分数从高到低进行等级划分,其中A等占10%,B等占25%,C等占40%,D等占20%,E等占5%。该示例严格按比例进行等级划分。我仔细查看了一下,A等占10%,那么这10%的最低分数为93,但划分等级时,有2个93未划为A等。若想剩下的2个93分也划为A等,该如何处理? |
-- 作者:有点蓝 -- 发布时间:2021/2/7 20:44:00 -- Dim cnt As Integer = DataTables("表A").DataRows.Count Dim vals() As Double = {0.1,0.25,0.4,0.20} Dim tops(3) As Integer For i As Integer = 0 To vals.length - 1 tops(i) = Math.Floor(cnt * vals(i)) Next Dim djs() As String = {"A","B","C","D"} Dim drs As List (of DataRow) For k As Integer = 0 To tops.length - 1 drs = DataTables("表A").SQLSelect("等级 is null",tops(k), "分数 Desc") For i As Integer = 0 To drs.Count - 1 drs(i)("等级") = djs(k) Next DataTables("表A").SQLUpdate(drs) Next DataTables("表A").SQLReplaceFor("等级","E", "等级 is null") DataTables("表A").Load Tables("表A").Sort = "分数 Desc"
|
-- 作者:lzzhyl001 -- 发布时间:2021/2/7 21:14:00 -- 完美解决,学习了,谢谢老师!!! |