Edit sql query.