繁体   English   中英

如何在 SQL 的另一个表中的两个数字之间找到一个表中的数字

[英]How to find one number in table between two number in another table in SQL

我有两张桌子 - 一张用于我的奖励,另一张用于我想获得奖励的产品,如下所示:

产品百分比

奖励表

例如,我想知道产品线 2 中的 78.12 如何获得奖励必须知道 78.12 在 40 和 87 之间,并且奖励必须在 0 和 1 之间

尝试这个:

select a.score,a.idline,
(select max(b.reward) from table2 b where a.idline = b.lineid and a.score > b.percentage) as  low,
(select min(b.reward) from table2 b where a.idline = b.lineid and a.score < b.percentage) as high
from table1 a

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM