add query to sum times