我有一个像这样的客户折扣表:
我有一个名为 @Total 的 deeared varialbe 来存储总金额
declare @Total numeric (12,2)
set @Total = (select Sum(LaborAmt) from #Data
group by Co)
我需要编写一个查询来根据@Total 获得更正的 discountRate。这意味着如果我的总金额为 3500000,它应该返回 2
SELECT dbo.budCustomerDisc.Customer, dbo.budCustDiscRate.DiscountRate
FROM dbo.budCustDiscRate INNER JOIN
dbo.budCustomerDisc ON dbo.budCustDiscRate.DiscountID = dbo.budCustomerDisc.DiscountId AND dbo.budCustDiscRate.JBCo = dbo.budCustomerDisc.JBCo
WHERE (dbo.budCustomerDisc.Customer = 165) .........
对不起,我只是不知道必须写它