0

从几年前开始讨论这个问题:MS Access 2003:检查数据是否在另一个表的范围内

如果我想在一个查询中检查多个数据是否在多个范围内,我该怎么办?我试图找出一个人每次测试的分数。我对每个测试都有不同的范围,因为一个测试可能满分 100,而另一个测试只能满分 10。

我是否必须使用上面链接的问题中的答案创建许多查询并结合起来,还是有更简单的方法?

表 A:

Name        Test1_Score    Test2_Score     Test3_Score        
Person A     205           98              5 
Person B     105           88              8
Person C     400           89              10

表 B:

Points       Test1_GradeReq    Test2_GradeReq     Test3_GradeReq
1              0               0               0
2              300             30              1
3              300             70              2
4              400             100             3
4

1 回答 1

0

以下获取每个测试和每个人的分数:

select a.name, a.Test1_Score, a.Test2_Score, a.Test3_Score,
       sum(iif(test1_score <= test1_gradeReq, 1, 0)) - 1 as Test1_Points,
       sum(iif(test2_score <= test2_gradeReq, 1, 0)) - 1 as Test2_Points,
       sum(iif(test3_score <= test3_gradeReq, 1, 0)) - 1 as Test3_Points
from TableA a, -- cross join
     TableB b
group by a.name, a.Test1_Score, a.Test2_Score, a.Test3_Score   

它假设点每一步增加一。

于 2013-04-04T19:41:48.840 回答