SELECT @charges=ISNULL(MAX(a.maxcharge), 0.00) FROM( SELECT (SELECT MAX(maxcharge) FROM(VALUES(ilongcharge),(iwidthcharge),(iheightcharge),(iweightcharge ),(ivolumecharge)) AS maxcharge(maxcharge))AS maxcharge FROM @temp) a