已知总销售额,进价,销售数量求售价。 有多种产品情况下用sql能解决么?
已知总销售额,进价,销售数量求售价。
有多种产品情况下用sql能解决么?
[解决办法]
;with t
as
(
select 3800 as amount,3 as num1,800 price1,2 as num2,300 price2
)
select *,
(3800 - (num1*price1+num2*price2)) *1.0/ (num1+num2) + price1 '电脑售价',
(3800 - (num1*price1+num2*price2)) *1.0/ (num1+num2) + price2 '手机售价'
from t