Fix SQL statements