以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 按人数多少分段问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=119501) |
-- 作者:sunion -- 发布时间:2018/5/25 21:12:00 -- 按人数多少分段问题 在学习FT的教程时,看到一个问题,始终不得解,请高手解答,比如按名次段分组,让前30、前50、前100固定,后面的分组按照人数多少来分,每组间隔100,最后一组除外 比如总人数为450人,那么代码生成的分组应该:前30,前50,前100,前200,前300,前400,后400; 比如总人数为680人,那么代码生成的分组应该:前30,前50,前100,前200,前300,前400,前500,前600,后600. 如何依据人数多少自动分组呢? 原始代码如下: dr0("前30") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 30 ") dr0("前50") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 50 ") dr0("前100") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 100 ") dr0("前200") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 200 ") dr0("前300") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 300 ") dr0("前400") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 400 ") dr0("前500") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 500 ") dr0("前600") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 600 ") dr0("前700") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 700 ") dr0("前800") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 800 ") dr0("后800") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] > 800 ") [此贴子已经被作者于2018/5/25 21:11:58编辑过]
|
-- 作者:有点蓝 -- 发布时间:2018/5/25 21:33:00 -- dr0("前30") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 30 ") dr0("前50") = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= 50 ") Dim cnt As Integer = 888 Dim idx As Integer For i As Integer = 1 To Math.Ceiling(cnt/100) idx = i*100 dr0("前" & idx) = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] <= " & idx) Next dr0("后" & idx) = dt.Compute("count(总分)", "[班级] = \'" & dr0("班级") & "\' and [考试名称] = \'" & ks & "\' and [总分排名] > " & idx)
|