在一个范围内编码数字的有效方法?

时间:2015-07-24 22:34:48

标签: logic

如果我有类似的话:

select sum(pets.dogs)
from pets, city
WHERE ST_Within(pets.dogs, city.geom);

这可以比每个value is between 1-1000 And if value is within 1-100, output A within 101-200, output B within 201-300, output C within 301-400, output D within 401-500, output E else, output F 语句更“有效”或更好地完成吗?

1 个答案:

答案 0 :(得分:1)

您可以使用值和输出之间的映射:

outputs = [ A, B, C, D, E, F, F, F, F, F]
output  = outputs[(int)((value - 1)/ 100)]