create function getYongJingXiShu(leasform varchar(255), factdate varchar(255)) returns varchar(255)
BEGIN	
	RETURN 
	(
	SELECT 
MAX(CASE WHEN lps.dis_attribute=1 THEN lps.fix_amount
WHEN lps.dis_attribute=2 THEN lps.dis_ratio
ELSE 0 END) aaa
FROM LB_PRODUCT_SALVAGE lps
WHERE lps.product_id=leasform
AND lps.effect_start<= factdate AND  lps.effect_end>=factdate);
    END;

