table1
id_product | id_category | price |
---|---|---|
1 | 11 | 120.00 |
2 | 11 | 100.00 |
3 | 11 | 92.00 |
table2
id_product | discount |
---|---|
1 | 20 |
产品只有 id_product 是 1 的有 20%的折扣,求打完折后的最低的价格
1
andrew2558 2022-10-14 20:41:03 +08:00 2
```mssql
select t1.Id_product,t1.Id_category,t1.price as originprice, t2.discount, FORMAT(t1.price*((100-ISNULL( t2.discount,0))/(100*1.0)), 'N') as newprice from table1 t1 left join table2 t2 on t1.Id_product= t2.Id_product ``` Id_product Id_category originprice discount newprice 1 11 120.00 20 96.00 2 11 100.00 NULL 100.00 3 11 92.00 NULL 92.00 |
2
rulai OP @andrew2558 感谢,我用的 mysql ,不过我参考学习下
|