$ 0 0 Code: [Select]total ( case when rank ( [PAY_DT] desc for report ) <= 5 then [AMT] else 0 end for report)/ 5