MS Access SQL 添加一个新列,该列是其他列的分数

MS Access SQL to add a new column which is a score from other columns

我目前有一个包含 20 列的 MS Access table。我需要添加一个新列,它是一个分数,0 - 5,基于其他列中的值

NewScore is defaulted to 0
if column1 is between 11 and 20 then NewScore is NewScore + 1
if column2 is between 7 and 10 then NewScore is NewScore + 1
if column3 is between 1 and 5 then NewScore is NewScore + 1
if column4 is between 1 and 20 then NewScore is NewScore + 1
if column5 is between 51 and 80 then NewScore is NewScore + 1

我已经使用多个查询完成了任务,然后是发出 COUNT 的最终查询,但必须有更清洁更有效的方法。

感谢您的帮助

使用switch:

select switch(column1 between 11 and 20, NewScore + 1,
              column2 between 7 and 10, NewScore + 1,
              . . . 
              1=1, NewScore
             ) as NewScore

我突然想到你可能真的想要这些加在一起。如果是:

select (iif(column1 between 11 and 20, 1, 0) +
        iif(column2 between 7 and 10, 1, 0) +
              . . . 
       ) as NewScore