首页 > 解决方案 > SQL 查找/连接值范围内的一个值

问题描述

输入表 这些是我的桌子。我想使用查询组合前两个表以获得如下所示的第三个表 连接的输出

标签: sqlms-access

解决方案


尝试这个:

select
  shipments.*, 
  (select floor from rates where shipments.weight between rates.floor and rates.ceiling) as floor,
  (select ceiling from rates where shipments.weight between rates.floor and rates.ceiling) as ceiling,
  (select rate from rates where shipments.weight between rates.floor and rates.ceiling) as rate
from shipments

我已经在 Access 2013 上对此进行了测试。


推荐阅读