Fix getTotalSum() IndexOutOfBoundsException if the query returned 0 results