日期:2014-05-17 浏览次数:20455 次
select a.Number400,a.FeeType, a.FixedFee,a.FeeTypeName,a.Fee1,a.Fee2,a.Fee3,a.Fee4,
b.Consumer1,b.Consumer2,b.Consumer3,b.Consumer4
from S_SaleManager a left join S_MonthlyData b
on b.Number400=a.Number400 and b.FeeType=a.FeeType
select a.Number400,a.FeeType, a.FixedFee,a.FeeTypeName,a.Fee1,a.Fee2,a.Fee3,a.Fee4,
b.Consumer1,b.Consumer2,b.Consumer3,b.Consumer4,
case when a.FeeType = 1 and a.Fee1*b.Consumer1+a.Fee2*b.Consumer2 > a.FixedFee)
then a.Fee1*b.Consumer1+a.Fee2*b.Consumer2
when a.FeeType = 2 and a.Fee3*b.Consumer3+a.Fee4*b.Consumer4 > a.FixedFee)
then a.Fee3*b.Consumer3+a.Fee4*b.Consumer4
else a.FixedFee
end
from S_SaleManager a
left join S_MonthlyData b
on b.Number400=a.Number400
and b.FeeType=a.FeeType
create procedure proc_testing(@Month int)
as
select a.Number400,a.FeeType, a.FixedFee,
a.FeeTypeName,a.Fee1,a.Fee2,a.Fee3,a.Fee4,
b.Consumer1,b.Consumer2,b.Consumer3,b.Consumer4,
case when a.FeeType = 1
and a.Fee1*b.Consumer1+a.Fee2*b.Consumer2 > a.FixedFee
then a.Fee1*b.Consumer1+a.Fee2*b.Consumer2
when a.FeeType = 2
and a.Fee3*b.Consumer3+a.Fee4*b.Consumer4 > a.FixedFee