Change getTotal() to get the correct count of rows with GROUP BY. Close #572