Fixed #883

FIxes #883 by renaming the inner query to $update_thread_ratings_query.