Replace ar_result_calculations with SQL median function.