Refactor SQL statements.