【发布时间】:2021-05-20 14:23:29
【问题描述】:
我有两张桌子,
PRODTBL consists of
Product Name
Quantity
PRICETBL consists of
Product Name
Min Qty
Max Qty
Price
我需要根据产品名称和数量在最小数量和最大数量内找到正确的价格。
样品:
PRODTBL
Product Name Quantity
Product1 16
Product2 100
Product1 4
Product3 7
PRICETBL
Product Name Min Qty Max Qty Price
Product1 0 5 1.99
Product1 6 10 1.59
Product1 11 999 1.09
Product2 0 10 10.00
Product2 11 100 5.00
Product2 101 9999 2.50
Product3 0 100 1.00
Product3 101 10000 0.50
Product3 10001 99999 0.25
从上面我要输出的示例数据:
Product1 16 1.09
Product2 100 5.00
Product1 4 1.99
Product3 7 1.00
【问题讨论】:
-
那你在问什么? 你尝试过什么自己来解决问题?为什么它不起作用?请不要将Stack Overflow 视为免费的编码服务,它不是免费的;这是一个问答网站。
-
您尝试加入表格吗?
-
看起来你应该研究的是
JOIN语法;语言的基本组成部分。您可能需要查看一些教程来帮助您开始学习该语言。 -
Larnu,非常感谢你的帮助和支持,我以后记得屏蔽你,以免浪费我的时间!
标签: sql sql-server