fixed typo in SQL query for rate calculation