gpt4 book ai didi

mysql - 为什么这些总数不匹配

转载 作者:行者123 更新时间:2023-12-01 00:07:23 24 4
gpt4 key购买 nike

我需要计算税金和折扣。这是我正在使用的公式,但查询返回很短。

((8.75+0)/100)*(50.00*1 - (50*1*.1/100)) as test,

MySQL 返回 4.370625,当我在计算器上计算 (0.0875 * 50 - 0.05) 时,我得到:3.875

我哪里错了?


让我们以这个真实世界为例

A single item for sale:
Quantity: 1.00
Price: $20.00
Tax: 8.75%
Discount: 10%

The tax should equal: $1.58
The subtotal without tax is $18.00
Total: $19.58 (after the discount and tax added)

如何编写查询以获取税金并单独计算以获取折扣?

最佳答案

你应该做 0.0875 * (50 - 0.05)。先差后乘。

((8.75+0)/100)*(50.00*1 - (50*1*.1/100))

( 8.75 /100)*(50 - 0.05 )

0.0875 *(50 - 0.05 )

0.0875 * 49.95

4.370625

你的真实例子(如果所有数字都像这里):

A single item for sale:
Quantity: 1.00
Price: $20.00
Tax: 8.75%
Discount: 10%


"Total Tax" = Quantity * (Price * (1. - (Discount / 100.)) * (Tax / 100.)
"Subtotal without tax" = Quantity * (Price * (1. - (Discount / 100.))
"Total" = Quantity * (Price * (1. - Discount / 100.) * (1. + Tax / 100.))

关于mysql - 为什么这些总数不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4887509/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com